【jQuery】jQuery常用选择器

148 阅读1分钟

注意:jQuery是一个集合,所有很多时候返回值也是一个集合

常用选择器

$("*") 			所有元素
$("#id") 		id选择器
$(".class")	 	类选择器
$("tagName") 		标签选择器
$("#id1,.class,tagName") 多条件选择
$(":first") 		一个
$(":last")  		最后一个
$(":eq(index)") 	下标为index
$(":not(selector)")	 所有不满足select筛选器的
$(":contains(text)") 	包含指定字符串的所有元素
$("[attribute=value]") 	属性等于属性值的
$("parent > child") 	选择指定parent的直接子元素child
$(" ancestor child") 	选择指定ancestor的所有子孙元素child
$("prev ~ siblings")	 选择prev 所有的兄弟元素
$("prev + next") 	直接跟在prev后面的next元素
$(this)  		当前对象选择器
.filter(selector)  	此过滤器也可以起到选择器作用

点击查看w3c上全部jQuery选择器