Bug Tracker

Opened 15 years ago

Closed 15 years ago

#2465 closed feature (invalid)

get dom element for added html

Reported by: jablko Owned by:
Priority: major Milestone: 1.2.4
Component: core Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:


Thank you for jQuery, it's an ingenious library : )

I frequently use jQuery to add markup to a page:


However I now need to access the dom element which jQuery constructs (I'm building a YUI button by passing the dom element to the button constructor).

I wish there were a way to access the dom element which jQuery constructs. For now, I use:

var bar = jQuery.clean('<div>bar</div>'); $('#foo').before(bar); var button = new YAHOO.widget.Button(bar);

  • however I guess clean is not a documented jQuery function, and so may disappear at any point?

So again, unless there's a better way to accomplish this, I whish jQuery exposed the function it uses to construct a dom element from an html string.

Also, I guess when ECMAScript for XML (E4X) is widely supported, I could use that, but until then, jQuery's clean function is the best I can think of...

Thanks again and best wishes, Jack

Change History (1)

comment:1 Changed 15 years ago by scott.gonzal

Resolution: invalid
Status: newclosed

$('<div>bar</div>') will return a jQuery object containing the element. There's no need to call clean directly.

var bar = $('<div>bar</div>');
Note: See TracTickets for help on using tickets.