Home >Web Front-end >JS Tutorial >jquery child element filter selector usage example_jquery

jquery child element filter selector usage example_jquery

WBOY
WBOYOriginal
2016-05-16 17:31:20964browse
Copy code The code is as follows:

:nth-child('index value')//Get the specified element The position of a child element under the index starts from 1;
//Even rows
//$('li:nth-child(even)').addClass('class1');
/ /Odd lines
//$('li:nth-child(odd)').addClass('class1');

//First line
//$('li: nth-child(1)').addClass('class1');
//$('li:first-child').addClass('class1');

//Only 1 child Element
$('li:only-child').addClass('class1');
Statement:
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