美文网首页
jQuery - 选择器

jQuery - 选择器

作者: AshengTan | 来源:发表于2016-08-07 15:07 被阅读13次

jQuery 选择器与 HTML DOM 操作类似,都是通过标签、id、类别、属性等来选取 HTML 元素。

$("*") -> 选取所有元素;
this: $(this) -> 选取当前 HTML 元素;
标签选择器(element): $("p") -> 选取所有 p 元素;
id 选择器(#id): $("#demo") -> 选取所有 id="demo" 的元素;
类别选择器(.class): $(".intro") -> 选取所有 class="intro" 的元素;
属性选择器([attribute]): $("[href]") -> 选取所有带有 href 属性的元素;
:first: $("p:first") -> 第一个 p 元素;
:last: $("p:last") -> 最后一个 p 元素;
:even: $("p:even") -> 所有偶数 p 元素;
:odd: $("p:odd") -> 所有奇数 p 元素;
:eq(index): $("li:eq(3)") -> 列表中的第四个元素(index 值从 0 开始);
:checked: $(":checked") -> 所有选中的元素(复选框或单选框);
:checkbox: $(":checkbox") -> 所有带有 type="checkbox" 的元素(
注意:若伪类选择器(即以“:”开始)前面没有其他选择器,则相当于使用("*"),所以 $(":checkbox") 相当于 $(":checkbox")**)。
其他选择器请参考 jQuery 选择器 - 菜鸟教程

相关文章

  • 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/prjlsttx.html