jquery select appended elements -
jquery select appended elements -
this question has reply here:
event binding on dynamically created elements? 13 answersfaced problem jquery doesn't allow select appended element. i've seen lot of advices how solve it. example:
var $li = $('<li><span>' + html + '</span></li>'); $('.top').append($li);
but can't help me in way. server list of records database in json format , in view , loop list , generate html structure.
for example:
$.getjson( "/searchbytype", data, function( info ) { $.each( data, function( key, val ) { $('items').append('<li class="item">'+ val.name + '</li>'); }); });
and want next click on li
item , manipulation. ul
list may contain 100-200 li
tags. ideas appreciated!
i think need event-delegation
$('body').on('click', 'li', function(){ // handler work dynamically created <li> });
jquery
Comments
Post a Comment