From the previous example, we can link jQuery statements together, which not only shortens the code length, but also often achieves special effects. Copy code The code is as follows: <br> $(function() {<br> $("div").addClass("css1").filter(function(index) {<br> Return index == 1 || $(this).attr("id") == "fourth";<br> }).addClass("css2");<br> });<br> <br> </div> The above code adds style css1 to the entire <div> list, then filters it, and then adds css2 style individually to the filtered elements. Without jQuery, it would be very troublesome to achieve the above effects. <p> </p>In the jQuery chain, subsequent operations take the result of the previous operation as the object. If you want the operation object to be the object of the previous step, you can use the end() method. <p> </p>Use the end() method to control the jQuery chain. <p> </p> <p></p> <div class="codetitle"><span><a style="CURSOR: pointer" data="16899" class="copybut" id="copybut16899" onclick="doCopy('code16899')">Copy code<u></u></a> The code is as follows:</span></div> <div class="codebody" id="code16899"> <script type="text/javascript"><br> $(function() {<br> $("p").find("span").addClass("css1").end().addClass("css2");<br> });<br> & Lt; span & gt; very nice, & lt;/span & gt; thanank you. <br> <br><br> <br>The above code searches for the <span> tag in <p>, then adds style css1, uses the end() method to set the operation object back to $("p") and adds style style css2.</div> In addition, you can also combine the previous two objects through andSelf() and process them together. <p> </p>Use the andSelf() method to control the jQuery chain. <p> </p> <p></p> <p></p> <div class="codetitle">Copy code<span><a style="CURSOR: pointer" data="94873" class="copybut" id="copybut94873" onclick="doCopy('code94873')"><u> The code is as follows:</u></a></span> <script type="text/javascript"></div> $(function() {<div class="codebody" id="code94873"> $("div").find("p").addClass("css1").andSelf().addClass("css2");<br> });<br> <br><br> <br>The above jQuery code first searches for the <p> tag in <div>, adds css1. This style is only valid for the <p> tag, and then uses the andSelf() method to separate <div> and <p> Combine them together, and then add style css2. This style is valid for both <div> and <p>. <br> <br>Effect: <br> <br><br> </div> <p>Copy code</p> <p></p> The code is as follows:<p></p> <div class="codetitle"><span> <div class="css2"><a style="CURSOR: pointer" data="34394" class="copybut" id="copybut34394" onclick="doCopy('code34394')"> <p class="css1 css2">First paragraph</p><u> <p class="css1 css2">Second paragraph</p></u> </a></span></div>