javascript - simulate click on dynamically added element -
i want simulate click on dynamically appended element. code used not work. don't know how can move forward script. used .trigger() method on load event of window. not work. code: $( function() { $.post("ajaxify.php", "name=heart", function(html) { $("#menu ul").append("<li>"+html+"</li>"); }); }); $(window).load( function() { $("#menu ul li").trigger("click"); }); when adding new 'li' elements menu, can trigger click on 1 list element: $('<li />').text('my text here').appendto('#menu ul').trigger('click');