Jquery determines the existence of child elements
1. Determine whether a child element exists // first level child element if($(“#specialId> Img ”). The length = = 0) If ($(” # specialId: from the (img) ”). The length = = 0) { //— no img submark — } Else { //— with img submark — }
Select a child element of a specific id under a specific id element $(“#form”). Children (”# t”) so
Select the child element under a specific id element; $(” ul# u> Li :nth-child(2)”) so
Determine whether an element exists If ($(” # myId ”). Length> 0) { / / there }