There must be something wrong. I don’t know what? see this on jsfiddle.
/*
$("p").live("click", function(){
$(this).after("<p>Another paragraph!</p>");
});
*/
$("p").on("click", function(){
$(this).after("<p>Now Click Me...Another paragraph!</p>");
});
I have selected jquery 1.7.2. and live is working fine but on does not attach click event. as per jquery documentation, on should be working as live has been deprecated. Any idea?
You’re not binding the
onevent correctly, you need to bind it to a parentjsFiddle: http://jsfiddle.net/h75BD/2/
Binding it using the
$('selector').on()syntax works exactly the same as.click(), the event is not delegated. If you want it to be delegated (aka live), you need to use the$('parent').on('click', 'selector')syntax.