Bug Tracker

Opened 11 years ago

Closed 11 years ago

#443 closed enhancement (invalid)

SPAM

Reported by: joern Owned by:
Priority: minor Milestone:
Component: core Version: 1.1a
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by joern)

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 (9)

comment:1 Changed 11 years ago by Johan

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

comment:2 Changed 11 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 11 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 11 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:5 Changed 11 years ago by joern

Description: modified (diff)

comment:6 Changed 11 years ago by anonymous

Status: newreopened

comment:7 Changed 11 years ago by joern

Resolution: invalid
Status: reopenedclosed

comment:8 Changed 11 years ago by anonymous

Resolution: invalid
Status: closedreopened

comment:9 Changed 11 years ago by brandon

Resolution: invalid
Status: reopenedclosed
Summary: Accept html markup as context paramter to jQuery constructorSPAM
Note: See TracTickets for help on using tickets.