美文网首页
jQuery选择器

jQuery选择器

作者: IMMYz | 来源:发表于2017-03-13 23:25 被阅读0次

最近工作新项目开坑,页面部分jquery使用的比较多,翻书看看,也是顺便整理一下jquery相关使用的知识。
常用的jQuery选择器:

选择器 实例 选取
* $("*") 选取所有元素
#id $("#id") id="id"的元素
.class $(".intro") 所有class="intro"的元素
element $("p") 所有p元素
.class.class $(".class1.class2") 所有class="class1"且class="class2"的元素
:first $("p:first") 选取第一个P元素
:last $("p:last") 选取最后一个P元素
:even $("p:even") 所有偶数的P元素
:odd $("p:odd") 所有奇数的P元素
:eq(index) $("ul li:eq(0)") 列出第一个li元素(从0开始计数)
:gt(no) $("ul li:gt(3)") 列出index大于3的元素
:lt(no) $("ul li:lt(3)") 列出index小于3的元素
:not(selector) $("input:not(:empty)") 所有部位空的input元素
:header $(":header") 所有标题的元素h1-h6
:animated $(":animated") 所有动画元素
:contains(text) $(":contains("test")") 包含指定字符串的所有元素
:empty $(":empty") 没有子元素节点的所有元素
:hidden $("p:hidden") 所有隐藏的P元素
:visible $("table:visible") 所有可见的表格
s1,s2,s3 $("th,td,.test") 所有带有匹配选择的元素
[attribute] $("[href]") 所有带有href属性的元素
[attribute=value] $("[name=test]") 所有name属性等于"test"的元素
[attribute!=value] $("[href!='#']") 所有href属性的值不等于"#"的元素(在""中要加上'')
[attribute$=value] $("[href$='.jpg']") 所有href属性的值包含以".jpg"结尾的元素
:input $(":input") 所有input元素
:text $(":text") 所有type="text"的input元素
:password $(":password") 所有type="password"的input元素
:radio $(":radio") 所有type="radio"的input元素
:checkbox $(":checkbox") 所有type="checkbox"的input元素
:submit $(":submit") 所有type="submit"的input元素
:reset $(":reset") 所有type="reset"的input元素
:button $(":button") 所有type="button"的input元素
:image $(":image") 所有type="image"的input元素
:file $(":file") 所有type="file"的input元素
:enabled $(":enabled") 所有激活的input元素
:disabled $(":disabled") 所有禁用的input元素
:selected $(":selected") 所有被选取的input元素
:checked $(":checked") 所有被选中的input元素

如果使用$(":input")来选择input元素,button元素也会被选中
<button>标签定义的是一个按钮,在button元素中可以放置文本与图像
<button>与<input type="button">相比功能更为强大一些
在IE浏览器中默认类型为"button",而在其他的浏览器中默认类型为"submit"

相关文章

  • jquery选择器书目录

    jquery选择器-基本选择器 jquery选择器-层级选择器 jquery选择器-基本过滤选择器 jquery选...

  • JQUERY一

    jQuery 元素选择器 jQuery 属性选择器 jQuery CSS 选择器 jQuery 事件 jQuery...

  • jQuser有选择器

    jQuery基本选择器 jQuery过滤选择器 jQuery层级选择器 jQuery筛选选择器(方法)

  • 选择器

    jQuery 元素选择器 jQuery 属性选择器 jQuery CSS 选择器

  • jQuery 基础

    jQuery jQuery操作DOM jQuery的选择器 基本选择器 层级选择器 过滤选择器 jQuery操作样...

  • jQuery

    jQuery jQuery操作DOM jQuery的选择器 基本选择器 层级选择器 过滤选择器 jQuery操作样...

  • jQuery选择器

    一、jQuery常用选择器 二、jQuery选择器优势 三、jQuery常用基本选择器 四、jQuery常用层次选...

  • JQuery基础知识

    jQuery操作DOM jQuery的选择器 基本选择器 层级选择器 过滤选择器 jQuery操作样式 css操作...

  • jQuery相关知识

    1、什么是jQuery选择器? jQuery选择器

  • jQuery选择器

    jQuery选择器 jQuery选择器完全继承了CSS的风格。学会使用选择器是学习jQuery的基础,jQuery...

网友评论

      本文标题:jQuery选择器

      本文链接:https://www.haomeiwen.com/subject/syaqnttx.html