javascript - jQuery live alternative (is there only on()?) -


i using live() using function @ ajax datas.

just like: $(".mydiv").live('click', function(){ alert("blablabla"); })

it working fine, if click on ajax datas '.mydiv'

but 'on' method doesn't support this?

$(".removebet").on('click',' i', function(){alert("blablabla");}); 

it doesn't work, if "i" come ajax datas. why? how can solve this?

the selector elements want bind using .on needs exist when .on called. if .removebet not exist when .on called (it sounds doesn't), .on won't bind anything.

your safest bet use

$(document).on("click", ".removebet i" ... 

ideally pick existing selector closer target descendants document.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -