Delegate (), live (), and jquerydelegate in jquery
The delegate () method adds one or more event handlers to the specified element (a child element of the selected element ).
For example, add an event to the span tag in the div whose id is showspan.
<Div id = "showspan"> <span> showspan ** showspan </span> </div> <span> outspan </span> <script language = "JavaScript"> <! -- // The effect is to click a section <div id = "showspan">. The span tag adds a span tag to the end of the span tag, you can also click to add a new span tag for the newly added span tag. The added tag does not need to listen to its click Event $ ("# showspan "). delegate ("span", "click", function () {$ (this ). after ("<span> showspan ** showspan </span>") ;}); // --> </SCRIPT>
The live () method attaches one or more event handlers to the selected element (you cannot add events to its child elements)
For example, add an event to the p tag.
<P class = "showp"> pppppppp </p> <script language = "JavaScript"> <! -- $ (". Showp "). live ("click", function () {$ (this ). after ("<p> pppppppp </p>") ;}); // --> </SCRIPT>
The above is all the content of this article. I hope you will like it.