Differences between next and children in Jquery

Source: Internet
Author: User
Next looks for nodes of the same level, and children looks for subnodes & lt; div & gt; & lt; ul & gt; & lt; liclass & quot; first & quot; & gt; & lt; ahref & quot; # & quot; & gt; this is Level 1 menu & lt;/a & gt; & lt; ul & gt; & lt; liclass & quot; second & quo next searches for nodes of the same level, and children searches for subnodes.
 


  • This is Level 1 menu 1

    • This is Level 2 menu 11

    • This is Level 2 menu 12



  • This is Level 1 menu 2

    • This is Level 2 menu 21

    • This is Level 2 menu 22.





 
 
The jquery code is as follows:
$ (Document). ready (function (){
$ ("Li. first"). hover (function (){
$ (This). children ("ul"). slideDown (); the ul node indicating the blacklist is found.
},
Function (){
$ (This). children ("ul"). slideUp ();
});
});
 
 
If it is changed to $ (this). next ("ul"), it cannot be found because there is no ul node at the same level as it!

From Xu Yue's column

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.