Ticket #443 (closed enhancement: invalid)
SPAM
| Reported by: | joern | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | core | Version: | 1.1a |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by joern) (diff)
Take this example:
html = "<ul><li>...</li></ul>";
html = $(html).find("li").css("color", "red").html();
It should be possible to write this as:
html = $("li", html).css("color", "red").html();
Change History
comment:2 Changed 6 years ago by anonymous
Well, I would change this behaviour:
$('li'). css("color","red") changes the DOM tree automatically
$('li',html).css("color","red") should also change the html-code automatically.
comment:3 Changed 6 years ago by Dave
I need some clarification on the semantics. In $("li", html) only the li elements are selected, right? So (with Johan's correction) there is a ul parent that binds them all and can be reached through parent() in later chained methods. What about the situation where the html fragment defines multiple sibling nodes that have no parent, and the selector doesn't grab them all?
html = "<p>test</p><div>one</div><p>two</p><p>three</p>"
$("div", html);
It seems like an html string with a single root context node is probably easy to implement by running it through jQuery.clean. But I am not sure what is supposed to happen when there are multiple nodes in the context.
comment:4 Changed 6 years ago by joern
$('li',html).css("color","red") should also change the html-code automatically.
Strings are immutable in javascript, therefore the html-code must be retrieved if needed.
Dave: It doesn't work.
comment:7 Changed 6 years ago by joern
- Status changed from reopened to closed
- Resolution set to invalid
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Good point, you'd want to correct the html example just to be clear though. ( html = "<ul><li>...</li></ul>"; )