Access Elements After Append
I need to access DOM elements after JQuery append. Let's say I have this:
- one
- two
Solution 1:
Make a jQuery collection of the html before appending it:
var addItems = function(html) {
var $items = $(html);
$('#items').append($items);
$items.foo();
}
Solution 2:
Here's a working example: http://jsfiddle.net/hunter/7UTA2/
var addItems = function(html) {
var $html = $(html);
$('#items').append($html);
$html.text("test");
}
This showcases that you still can manipulate the text (or whatever attribute) of the items since you still have a reference to the collection.
Post a Comment for "Access Elements After Append"