Jquery method of hiding all subordinate elements: 1. Use the find() method to obtain all subordinate elements (including subsets of subsets); 2. Use the hide() method to hide the obtained elements, syntax "Specify element.find().hide();".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
jquery hides all subordinate elements
Implementation ideas:
Use the find() method to Get all subordinate elements (including subsets of subsets)
Use the hide() method to hide the obtained elements
Implementation code:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="js/jquery-1.10.2.min.js"></script> <script> $(document).ready(function() { $("button").click(function() { $("div").find("*").hide(); }); }); </script> </head> <body> <div style="border: 1px solid red;"> <ul> <li>姓名:aa</li> <li>年龄:25</li> <li>爱好: <ul> <li>运动</li> <li>听音乐</li> <li>烹饪</li> </ul> </li> </ul> </div> <button>隐藏下级所有元素</button> </body> </html>
[Recommended learning: jQuery video tutorial, web front-end development]
The above is the detailed content of How to hide all subordinate elements in jquery. For more information, please follow other related articles on the PHP Chinese website!