1.不能有空格,空格表示索引为1的
:first
:last
:gt(5) 索引大于5的标签
:lt(5)索引小于5的标签
:header:选取h1h2h3h4h5之类的标签
:eq(5):索引等于5的标签
:not(selector1):
:even 偶数标签
:odd 奇数标签
<script type="text/javascript">
$(function () {//选取所有的p元素
//$('p').css('backgroundColor', 'red');
//选取首个p元素设置属性
//$('p:first').css('backgroundColor', 'red');
//选取最后一个p元素设置属性
//$('p:last').css('backgroundColor', 'red');
//选取偶数元素
//$('p:even').css('backgroundColor', 'red');
//选取奇数元素
//$('p:odd')css('backgroundColor', 'red');
//索引大于2的元素
//$('p:gt(2)')css('backgroundColor', 'red');
//索引小于3的元素
//$('p:lt(3)')css('backgroundColor', 'red');
//选取页面上所有的p元素,除了应用了cls类的那些p元素
//$('p:not(.cls)').css('backgroundColor', 'red');
//选取header标签,即选择h1....等标签
//$('h1,h2,h3').css('backgroundColor', 'red');
//$(':header').css('backgroundColor', 'red');
})
</script>