jQuery 1.7's .on()
and .off()
methods are supposed to replace .live()
and such.
I tried it with a dynamic item:
$(".myList").on('click', function(e){
alert('hello world');
});
This is not working for me for elements added after DOM is loaded.
Is code above a valid example for jQuery 1.7's .on()
and .off()
methods?
See http://blog.jquery.com/2011/11/03/jquery-1-7-released/ for live() -> on/off() (and other) examples.
This is their example for converting live to on:
So your example becomes to:
Here is a little example:
http://jsfiddle.net/zzSjK/
"Bind" with:
And "unbind" with: