jquery select appended elements -



jquery select appended elements -

this question has reply here:

event binding on dynamically created elements? 13 answers

faced 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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -