开发者

Dynamically adding content to a tree menu

开发者 https://www.devze.com 2023-03-12 13:44 出处:网络
What\'s the best way to dynamically add elements to a tree menu in jquery? When I use the append() method to add another (li) \'some code\' (/li) to extend my tree menu, the code is added but doesn\'t

What's the best way to dynamically add elements to a tree menu in jquery? When I use the append() method to add another (li) 'some code' (/li) to extend my tree menu, the code is added but doesn't become live. Is there another method I should use开发者_C百科 instead of append(). Any help is appreciated. Brett


It totally depends on how you attached events in the first place:

To have events attached also to elements created after the DOM is ready you could use live()

$('yourselector').live("click", function(){
         //put what to do after a click event
});
0

精彩评论

暂无评论...
验证码 换一张
取 消