jquery 学习笔记——选择元素
2011-08-18 15:51
246 查看
选择DOM元素和创建新的DOM元素
Element #id .class 以及组合,如:label.out
Selector1,selector2,selector3: 或选择器
[selector1],[selector2],[selector3]: 与选择器
Ancestor descendant ,如 div tr
Parent>child , 如tr>td
Pre +next:匹配前面是临近兄弟节点pre的所有next元素 (紧相邻)
Pre~siblings: 匹配前面是兄弟节点pre的所有siblings元素 (不紧相邻)
E[attr=value] 严格相等
E[attr^=value] 开始
E[attr$=value]
E[attr*=value]
E[attr!=value]
E:has(selector) 匹配名称为E,且包含选择器对应的后代节点 的元素
这两个,contains用于匹配文本 has用于匹配selector
:empty 不包含子元素或文本的空元素
:parent 包含子元素或文本的节点,与:empty正好相反
:last
:eq(n) :lt(n) :gt(n) :even :odd
:checkbox input[type=checkbox]
:file input[type=file]
:header 匹配h1 h2 h3之类的标题元素
:hidden
:image
:input input select textarea button
:password
:radio
:reset
:submit
:text input[type=text]
:selected 选择已选中的选项元素 <option selected>
:disabled
:focus 当前焦点对象
:enabled
:first-child 返回第一个子元素
:last-child
:only-child 返回没有兄弟节点的所有元素
例如: li:first-child 先找到所有的li,再找到li的父元素,选择父元素下的第一个元素, 和first相比,first只会选择第一个,而first-child会选择多个。
:animated 匹配没有在执行动画效果的元素
1. 选择被操作的元素
选择器实验室 chapter2/lab.selectors.html1.1 CSS选择器
相同于CSS中的选择方法Element #id .class 以及组合,如:label.out
Selector1,selector2,selector3: 或选择器
[selector1],[selector2],[selector3]: 与选择器
1.2 层次选择器
利用彼此之间的关系来选择元素,如:Ancestor descendant ,如 div tr
Parent>child , 如tr>td
Pre +next:匹配前面是临近兄弟节点pre的所有next元素 (紧相邻)
Pre~siblings: 匹配前面是兄弟节点pre的所有siblings元素 (不紧相邻)
1.3 属性选择器
E[attr]:有attr属性的元素EE[attr=value] 严格相等
E[attr^=value] 开始
E[attr$=value]
E[attr*=value]
E[attr!=value]
1.4 内容选择器
E:Contains(text) 匹配名称为E,且文本内容包含text 的元素E:has(selector) 匹配名称为E,且包含选择器对应的后代节点 的元素
这两个,contains用于匹配文本 has用于匹配selector
:empty 不包含子元素或文本的空元素
:parent 包含子元素或文本的节点,与:empty正好相反
1.5 位置选择器
:first:last
:eq(n) :lt(n) :gt(n) :even :odd
1.6 可见选择器
:hidden :visible1.7 表单选择器
:button input[type=reset] input[type=submit] input[type=button]或button:checkbox input[type=checkbox]
:file input[type=file]
:header 匹配h1 h2 h3之类的标题元素
:hidden
:image
:input input select textarea button
:password
:radio
:reset
:submit
:text input[type=text]
1.8 表单属性选择器
:checked 匹配checked的radio和checkbox:selected 选择已选中的选项元素 <option selected>
:disabled
:focus 当前焦点对象
:enabled
1.9 子元素选择器
:nth-child(n/even/odd/Xn+Y) n从1开始,选择子节点:first-child 返回第一个子元素
:last-child
:only-child 返回没有兄弟节点的所有元素
例如: li:first-child 先找到所有的li,再找到li的父元素,选择父元素下的第一个元素, 和first相比,first只会选择第一个,而first-child会选择多个。
1.10其他选择器
:Not(selector) 对选择器执行非运算:animated 匹配没有在执行动画效果的元素
相关文章推荐
- jQuery 学习笔记 选择元素
- JQUERY1.9学习笔记 之内容过滤器(二) 空元素选择器
- 【jQuery学习笔记----元素遍历】
- 韩顺平_php从入门到精通_视频教程_第13讲_选择器使用细节_块元素和行内元素_盒子模型_盒子模型经典应用①_学习笔记_源代码图解_PPT文档整理
- learning jQuery 学习笔记十一(+jQuery 1.4.1 API)-- DOM操作-基于命令改变页面 ----移动元素
- 【jQuery学习笔记------选择器】
- jquery学习笔记-jQuery操纵DOM元素属性 attr()和removeAtrr()方法
- jQuery学习笔记--remove()删除选择的节点,applend() 添加到节点
- learning jQuery 学习笔记十三(+jQuery 1.4.1 API)-- DOM操作-基于命令改变页面 ----复制元素及其它
- jQuery之表单域选择器学习笔记
- Jquery学习笔记——处理表单元素
- “jquery于each方法和选择”学习笔记
- jquery笔记之属性选择器 查找以某种条件开头的页面元素
- jQuery学习笔记(三) 元素处理
- Jquery学习笔记:操作form表单元素之二(复选框和单选框)
- JQuery学习笔记-内容选择器
- jQuery学习笔记---模态对话框,添加、编辑、删除(注意:click中绑定click,delegate:给后来元素自动添加事件)
- jQuery学习笔记(二)—— 操作DOM元素
- HTML&CSS基础学习笔记1.25-input标签的选择文件和隐藏元素
- jquery学习手记(4)元素的选择与操作