JQuery end () instance

Source: Internet
Author: User

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>

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.