×

jQuery子元素过滤选择器

作者:yuchen2018.01.30来源:Web前端之家浏览:9683评论:0
关键词:JQueryJS

jQuery子元素过滤选择器。

:nth-child('索引值')//获取指定元素下的某个子元素的位置,索引从1开始;

//偶数行 
//$('li:nth-child(even)').addClass('class1'); 
//奇数行 
//$('li:nth-child(odd)').addClass('class1'); 

//第一行 
//$('li:nth-child(1)').addClass('class1'); 
//$('li:first-child').addClass('class1'); 

//只有1个子元素 
$('li:only-child').addClass('class1');

 

您的支持是我们创作的动力!
温馨提示:本文作者系yuchen ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://www.jiangweishan.com/article/svg1488038400654.html

网友评论文明上网理性发言 已有0人参与

发表评论: