I’m using jQuery.append() to add some elements dynamically. Is there any way to get a jQuery collection or array of these newly inserted elements?
So I want to do this:
$("#myDiv").append(newHtml);
var newElementsAppended = // answer to the question I'm asking
newElementsAppended.effects("highlight", {}, 2000);
There’s a simpler way to do this:
This turns things around by first creating
newHtmlwithjQuery(html [, ownerDocument ]), and then usingappendTo(target)(note the “To” bit) to add that it to the end of#mydiv.Because you now start with
$(newHtml)the end result ofappendTo('#myDiv')is that new bit of html, and the.effects(...)call will be on that new bit of html too.