css选择器
名称例子标签选择器$(‘div’)ID选择器$(’#test’)类选择器$(’.test’)通用选择器$(’*’)群组选择器$(‘div,span,p’)层级选择器
名称例子子元素选择器$(‘parent > child’)后代选择器$(‘form input’)紧邻同辈选择器$(‘div + span’)相邻同辈选择器$(‘input ~ p’)表单域选择器
名称例子:input 选择器$(’:input’):text 选择器$(’:text’):password 选择器$(’:password’):submit 选择器$(’:submit’)简单过滤选择器
名称例子:first 选择器$(‘selector:first’):odd 选择器$(‘selector:odd’):even 选择器$(‘selector:even’):not 选择器$(‘selector1:not(selector2)’)内容过滤选择器 :empty
//作用:找到既没有文本内容也没有子元素的指定元素 var $div = $("div:empty") console.log($div):parent
//作用:找到有文本内容或有子元素的指定元素 var $div = $("div:parent") console.log($div):contains(text)
//作用:找到包含指定文本内容的指定元素 var $div = $("div:contains('我是div')") console.log($div):has(selector)
//作用:找到包含指定子元素的指定元素 var $div = $("div:has('span')") console.log($div)属性过滤选择器
名称例子包含属性选择器$(‘div[id]’)属性等于选择器选择器$(‘input[name = accept]’)子元素过滤选择器
名称例子:first-child 选择器$(‘ul:first-child’):last-child 选择器$(‘ul:last-child’):nth-child 选择器$(‘selector:nth-child()’)表单域属性过滤选择器
名称例子:checked 选择器$(‘selector:checked’):disabled 选择器$(‘selector:disabled’):selected 选择器$(‘selector:selected’)可见性过滤选择器
名称例子:hidden 选择器$(‘selector:hidden’):visible 选择器$(‘selector:visible’)