JQuery筛选器
来源:互联网 发布:linux删除上锁文件 编辑:程序博客网 时间:2024/05/05 18:09
jQuery提供了强大的选择器让我们获取对象。在这边,我人为地将jQuery选择器分为两大部分:选择对象和筛选条件。选择对象表示要获取什么对象,筛选条件是对获取的对象进行筛选,最终留下符合某些特征的对象。
1.选择对象
1).基本
·#id 根据给定的ID匹配一个元素。例如:$("#id")
·element 根据给定的元素名匹配所有元素。例如:$("div")
·.class 根据给定的类匹配元素。例如:$(".style1");
·* 匹配所有元素。例如:$("*")
·selector1,selector2,selectorN 将每一个选择器匹配到的元素合并后一起返回。例如:$("#id,div,.style1")
2).表单
·:button 匹配所有按钮。例如:$(":button")
·:checkbox 匹配所有复选框。例如:$(":checkbox")
·:file 匹配所有文件域。例如:$(":File")
·:hidden 匹配所有不可见元素,或者type为hidden的元素。例如:$("input:hidden")
·:image 匹配所有图像域。例如:$(":image")
·:input 匹配所有 input, textarea, select 和 button 元素。例如:$(":input")
·:password 匹配所有密码框。例如:$(":password")
·:radio 匹配所有单选按钮。例如:$(":radio")
·:reset 匹配所有重置按钮。例如:$(":reset")
·:submit 匹配所有提交按钮。例如:$(":submit")
·:text 匹配所有的单行文本框。例如:$(":text")
·:header 匹配如 h1, h2, h3之类的标题元素。例如:$(":header").css("background", "#EEE");
2.筛选条件
1).属性筛选
·[attribute*=value] 匹配给定的属性是以包含某些值的元素。例如:$("input[name*='man'")
·[attribute!=value] 匹配所有含有指定的属性,但属性不等于特定值的元素。例如:$(input[name!='man');
·[attribute$=value] 匹配给定的属性是以某些值结尾的元素。例如:$("input[name$='man']")
·[attribute=value] 匹配给定的属性是某个特定值的元素。例如:$("input[name='man']");
·[attribute] 匹配包含给定属性的元素。例如:$("div[id]")
·[attribute^=value] 匹配给定的属性是以某些值开始的元素。例如:$("input[name^='man']")
·[selector1][selector2][selectorN] 同时满足多个条件。例如:$("input[id][name$='man']")
·:hidden 匹配所有的不可见元素。例如:$("tr:hidden")
·:visible 匹配所有的可见元素。例如:$("tr:visible")
·:checked 匹配所有选中的被选中元素(复选框、单选框等,不包括select中的option)。例如:$("input:checked")
·:disabled 匹配所有不可用元素。例如:$("input:disabled")
·:enabled 匹配所有可用元素。例如:$("input:enabled")
·:selected 匹配所有选中的option元素。例如:$("select option:selected")
2).内容筛选
·:contains(text) 匹配包含给定文本的元素。例如:$("div:contains('John')")
·:empty 匹配所有不包含子元素或者文本的空元素。例如:$("td:empty")
·:has(selector) 匹配含有选择器所匹配的元素的元素。例如:$("div:has(p)");
·:parent 匹配含有子元素或者文本的元素。例如:$("td:parent")
3).层级筛选
·ancestor descendant 在给定的祖先元素下匹配所有的后代元素。例如:$("form input")
·parent > child 在给定的父元素下匹配所有的子元素。例如:$("form > input")
·prev + next 匹配所有紧接在 prev 元素后的 next 元素。例如:$("label + input")
·prev ~ siblings 匹配 prev 元素之后的所有 siblings 元素。例如:$("form ~ input")
·:first-child 匹配第一个子元素。例如:$("ul li:first-child")
·:last-child 匹配最后一个子元素。例如:$("ul li:last-child")
·:nth-child(index/even/odd/equation) 匹配其父元素下的第N个子或奇偶元素。例如:$("ul li:nth-child(2)")
·:only-child 如果某个元素是父元素中唯一的子元素,那将会被匹配。例如:$("ul li:only-child")
4).方法筛选
·:animated 匹配所有正在执行动画效果的元素。例如:$("div:animated");
·:eq(index) 匹配一个给定索引值的元素。例如:$("tr:eq(1)")
·:even 匹配所有索引值为偶数的元素,从 0 开始计数。例如:$("tr:even")
·:first 匹配找到的第一个元素。例如:$("tr:first")
·:gt(index) 匹配所有大于给定索引值的元素,从 0 开始计数。例如:$("tr:gt(0)")
·:last 匹配找到的最后一个元素。例如:$("tr:last")
·:lt(index) 匹配所有小于给定索引值的元素。例如:$("tr:lt(2)")
·:not(selector) 去除所有与给定选择器匹配的元素。例如:$("input:not(:checked)")
·:odd 匹配所有索引值为奇数的元素,从 0 开始计数。例如:$("tr:odd")
·element
·.class
·*
·selector1,selector2,selectorN
2).表单
·:button
·:checkbox
·:file
·:hidden
·:image
·:input
·:password
·:radio
·:reset
·:submit
·:text
·:header
2.筛选条件
1).属性筛选
·[attribute*=value]
·[attribute!=value]
·[attribute$=value]
·[attribute=value]
·[attribute]
·[attribute^=value]
·[selector1][selector2][selectorN]
·:hidden
·:visible
·:checked
·:disabled
·:enabled
·:selected
2).内容筛选
·:contains(text)
·:empty
·:has(selector)
·:parent
3).层级筛选
·ancestor descendant
·parent > child
·prev + next
·prev ~ siblings
·:first-child
·:last-child
·:nth-child(index/even/odd/equation)
·:only-child
4).方法筛选
·:animated
·:eq(index)
·:even
·:first
·:gt(index)
·:last
·:lt(index)
·:not(selector)
·:odd
- JQuery筛选器
- jquery筛选器
- JQuery筛选器
- jQuery强大筛选器
- JQuery筛选器
- JQuery筛选器大全
- jquery筛选器图
- jQuery筛选器children()
- JQuery筛选器
- jQuery筛选器知识
- jQuery基本筛选器
- jQuery筛选器
- JQuery的强大筛选器
- jQuery筛选器children()详解
- 解读jQuery筛选器children()
- jQuery笔记-jQuery筛选器children()详解
- jquery筛选
- Jquery 筛选
- Javascript+Dom编程艺术:美术馆例题(将js与文档内容分离的几种实现)
- 实习日记015(0805)
- Oracle TNSNAMES.ORA配置
- 内存管理原理
- 笑笑吧
- JQuery筛选器
- 够毒
- Shell排序
- 以system权限启动应用程序
- 记着这个好东西--TaskInfo
- 大项目源码学习方法
- eclipse+ddm调试android源码
- .NET实现的四层拓扑结构
- ActionScript3.0知识要点----核心类