本系列文章分为:基本篇、层次篇、简单篇、内容篇、可见性篇、属性篇、子元素篇、表单篇、表单对象属性篇共9篇文章。
本篇讲解::nth-child(index/even/odd/equation),:first-child,:last-child,:only-child的用法。
您对本系列文章有任何建议或意见请发送到邮箱:sjzlgt@qq.com
由于是第一次写技术性系列文章,难免会出错或代码BUG,欢迎指出,在此谢过!
您可以到jQuery官网来学习更多的有关jQuery知识。
运行后,请刷新下,因为需要加载jquery,默认是输出,不会加载远程的js文件的。
.div
{
width:95%;
margin-left:15px;
margin-top:15px;
margin-right:15px;
padding-left:5px;
padding-top:5px;
padding-bottom:5px;
background-color:#ccc;
border:#999 1px solid;
line-height:30px;
font-size:13px;
font-family:微软雅黑;
}
.blue{color:Blue;}
.green{color:Green;}
.button{border:green 1px solid;width:100px;}
.xiaobiao{ font-weight:bold;}
.red_test{background-color:red; color:White; width:300px; height:30px;}
.li_test{border:#000 1px solid;}
jQuery-Selectors(选择器)的使用(七、子元素篇)
本系列文章主要讲述jQuery框架的选择器(Selectors)使用方法,我将以实例方式进行讲述,以简单,全面为基础,不会涉及很深,我的学习方法:先入门,后进阶!
本系列文章分为:基本篇、层次篇、简单篇、内容篇、可见性篇、属性篇、子元素篇、表单篇、表单对象属性篇共9篇文章。
本篇讲解:[attribute],[attribute=value],[attribute!=value],[attribute^=value],[attribute$=value],[attribute*=value],[selector1][selector2][selectorN]的用法。
您对本系列文章有任何建议或意见请发送到邮箱:sjzlgt@qq.com
由于是第一次写技术性系列文章,难免会出错或代码BUG,欢迎指出,在此谢过!
您可以到jQuery官网来学习更多的有关jQuery知识。
版权所有:code-cat 博客:http://www.cnblogs.com/bynet 转载请保留出处和版权信息!
在IE6、IE7、火狐下测试过了,效果都很明显。
1. :nth-child(index/even/odd/equation)用法
定义:匹配其父元素下的第N个子或奇偶元素 ‘:eq(index)’ 只匹配一个元素,而这个将为每一个父元素匹配子元素。:nth-child从1开始的,而:eq()是从0算起的!
可以使用如下语法:
:nth-child(2) //索引为2的元素
:nth-child(even) //索引为偶数元素
:nth-child(odd) //索引为奇数元素
:nth-child(3n) //索引为3 * n的元素,n=0,1,2,3,4…,呃…3不是死的,你可以换成如1,2,4,5,6…之类的,下同
:nth-child(3n+1) //索引为3 * n + 1的元素,n=0,1,2,3,4…










