code尘

导航

【jQuery>属性过滤器

<script type="text/javascript">
// $('td:odd').css('background','black')//$('selector:odd')奇数
// $('td:even').css('background','red')//$('selector:even')偶数
// $('td:eq(0)').css('background','grey')//$('selector:eq(index)')指定
// $('td:lt(1)').css('background','grey')//$('selector:lt(index)')小于
// $('td:gt(1)').css('background','grey')//$('selector:gt(index)')大于
// $('td:contains(2)').css('background','grey')//$('selector:contains(content)')指定内容
// $('td:empty').css('background','grey')//$('selector:empty(content)')其下的所有空的元素
// $('td:lt(1),td:gt(3)').css('background','grey')//$('selector:empty(content),selector:gt(index),...')其下的所有空的元素
//逗号隔开一次多访问

//‘属性’过滤器
// $('td[tt=1]').css('background-color','red')
// $('td[tt!=1]').css('background-color','red')
// $('td[src='sda']')
// 语法:$(selector[property=**])访问其下属性等于指定属性的元素
</script>
<!-- 第二天结束 -->

<!-- 属性过滤选择器 -->
<!-- <script type="text/javascript">
// $('td:contains(2)').css('background','red')//$(tag:contains(content))//访问指定内容
// $('td:has(span)').css('background','red')//$(tag:has(tag_1))//访问其下的指定标签
// $('td:parent()').css('background','red')//$(tag:parent())//访问其下有内容的元素
// $('[tt=1]').css('background','red')//$([attribute=属性名])//访问属性匹配的的元素
// $('[class^=li]').css('background','red')//$([attribute^=模糊属性名])//访问其下模糊属性匹配的元素,不支持数字开头
// $('[class*=li]').css('background','red')//$([attribute*=模糊属性名])//访问其下模糊属性匹配的元素,支持数字开头
// $('[class$=01]').css('background','red')//$([attribute*=模糊属性名])//访问属性以什么结尾的匹配元素
// $('[class$=01][class^=li]').css('background','red')//$([attribute*=模糊属性名][][])//多次结合匹配

// $('li:first-child').css('background','red')//$(tag:first-child)其父元素的第一个儿子
// $('li:last-child').css('background','red')//$(tag:first-child)其父元素的最后一个儿子
// $('li:only-child').css('backprop他ground','red')//$(tag:first-child)其父元素只有一个儿子的元素
</script> -->

posted on 2021-10-18 14:51  code尘  阅读(83)  评论(0编辑  收藏  举报