Skip to main content

Bug Tracker

Side navigation

#443 closed enhancement (invalid)

Opened November 28, 2006 07:07AM UTC

Closed February 07, 2007 07:58PM UTC

SPAM

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

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();
Attachments (0)
Change History (9)

Changed November 28, 2006 09:41AM UTC by Johan comment:1

Good point, you'd want to correct the html example just to be clear though.

( html = "<ul><li>...</li></ul>"; )

Changed November 28, 2006 03:35PM UTC by anonymous comment:2

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.

Changed November 28, 2006 05:06PM UTC by Dave comment:3

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.

Changed November 29, 2006 08:08PM UTC by joern comment:4

   $('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.

Changed December 11, 2006 09:44AM UTC by joern comment:5

description: Take this example:\ \ {{{\ html = "<ul><li>...</li></li>";\ html = $(html).find("li").css("color", "red").html();\ }}}\ \ It should be possible to write this as:\ \ {{{\ html = $("li", html).css("color", "red").html();\ }}}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();\ }}}

Changed January 15, 2007 09:38PM UTC by anonymous comment:6

status: newreopened

Changed January 15, 2007 10:21PM UTC by joern comment:7

resolution: → invalid
status: reopenedclosed

Changed January 16, 2007 09:12PM UTC by anonymous comment:8

resolution: invalid
status: closedreopened

Changed February 07, 2007 07:58PM UTC by brandon comment:9

resolution: → invalid
status: reopenedclosed
summary: Accept html markup as context paramter to jQuery constructorSPAM