Home > Web Front-end > JS Tutorial > jquery sample code to determine whether the child elements of an element exist_jquery

jquery sample code to determine whether the child elements of an element exist_jquery

WBOY
Release: 2016-05-16 17:01:26
Original
901 people have browsed it

jquery determines whether a child element exists

1. Determine whether the sub-element exists
//First-level sub-element if($("#specialId>img").length==0)
if ($( " #specialId:has(img)" ).length==0)                                                                                                                 
//-------There is an img sub-tag------
}


2. Select the specific id sub-element under the specific id element

$("#form" ).children( "#t" ) like this

3. Select the child element under a specific id element
$("ul#u> ;li:nth-child(2)" ) So

4. Determine whether an element exists
if ($( "#myId" ).length>0)
{
//Existence }

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template