The event handlers attached to jquery through the Live () method apply to the current and future elements of the matching selector (such as new elements created by the script)
$ ("ul"). Append ("<li class= ' name ' > </li>");
"Error" is then done in the following way, which is not available:
$ (". Name"). Click (function () {Alert ("node acquired after append");})
The correct way to do this is:
$ (". Name"). Live ("click", Function () {alert ("acquired");});
After jquery 1.7+, use on instead of the Live,on () method to add one or more event handlers on the selected element and child elements
<div id= "One" ></div>$ (' #one '). Append ("<P id= ', ' >test1</p>" ); Append results: $ (' #one '). Append ("<P id= ', ' >test1</p>");
"Error" will not pop up in the following way directly:
$ ("#two"). On ("click", Function (data) {alert (data);});
"Correct" is changed to the following way:
$ ("body"). On ("click","#two", function (data) {alert (data);});
The event handlers attached to jquery through the Live () method apply to the current and future elements of the matching selector (such as new elements created by the script)