jquery to determine if the child elements of an element exist in sample code

Source: Internet
Author: User

This article is mainly about the elements of jquery to determine the existence of the child elements of the sample code is introduced, need friends can come to the reference, I hope to help you

jquery determines whether a child element exists or not, determining whether a child element exists//First level child element if ($ ("#specialId >img"). Length==0) if ($ ("#specialId: Has (IMG)"). Lengt h==0) {//-----no IMG child Tag-----} else {//-------has an IMG tag------} Two, select a specific ID element     A specific ID child element $ ("#form"). Children ("#t") three, select the child element under a specific ID element $ ("Ul#u>li:nth-child (2)") so four, to determine whether an element exists if ($ ("#myId"). length>0) {//exist}

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.