JQuery end () instance
Instance 1,
<Body> <p> <span> Hello </span>, how are you? </P> <script> $ ("p "). find ("span" cmd.end(cmd.css ("border", "2px red solid"); </script> </body> // description // $ ("p "). find ("span") indicates to find the SPAN element under the P element // but I want to change the border of P, then I will return to the P element (that is, return to P from the SPAN, is restored to the previous status) // $ ("p "). find ("span "). the end () Statement is returned. // $ ("P"). find ("span" ).end().css ("border", "2px red solid") sets the border of P.
Example 2,
<Div id = "test">
/// Description // when you click the div whose id is test, first locate the p tag in the div and hide it. // The end () method is used to end the reference to the p tag. In this case, the # test (jQuery object) is returned, so that the subsequent hide () method hides the div. Instance 3,
<script type="text/javascript"> $(function(){ $('<input type="button" value="click me" /><input type="button" value="triggle click me" /><input type="button" value="detach handle" /><input type="button" value="show/hide text" />').appendTo($('body')); $('input[type="button"]').eq(0).click(function(){ alert('you clicked me!'); }) .end().eq(1).click(function(){ $('input[type="button"]:eq(0)').trigger('click'); }) .end().eq(2).click(function(){ $('input[typw="button"]:eq(0)').unbind('click'); }) .end().eq(3).toggle(function(){ $('.panel').hide('slow'); },function(){ $('.panel').show('slow'); }); })</script><div class="panel">welcome to jQuery!</div>