jquery_selector03

属性选择器,和css是一致的

$("[name=one]").css('color',"red");

$("[name|=on]").css("font-size',"50px");

//属性值以hello结尾的

$("[data$=hello]").css("font-size","50px");

//属性值以hello开头的

$("[data^=hello]").css("color","red")

和css中的伪类选择器一致

$(".one li:nth-child(5)").css("font-size","20px");

//nth-child把所有同辈元素都计数了

//只把符合条件的同辈元素计数

$(".one li:nth-child(5)").css("color","red");

$(".one li:eq(4)").css("font-size","50px")

//:nth-child伪类可以传递表达式

$(".one li:nth-child(2n)").css("border","1px solid red")

$(".one li:nth-child(2n+1)").css("border","1px solid red")

//nth-of-type

在具体选择时从1开始跟nth-child全部相同

在计数时同eq只把符合条件的同辈进行计数.



猜你喜欢

转载自blog.csdn.net/yahooG/article/details/77484688