*         Matches any element.( 匹配任何元素 )

声明     $("*")

JQuery CSS 基本选择器 详解


E         Matches all element with tag name E. ( 匹配tag name为 E 的所有元素 )

声明     $("input")

JQuery CSS 基本选择器 详解


E F         Matches all elements with tag name F that are descendents of E. (匹配tag name 为F,作为E的后代节点的所有元素)

声明     $("ul  a")

JQuery CSS 基本选择器 详解

对应Html:

<ul class="myList">
  <li><a href="http://jquery.com">jQuery supports</a>
    <ul>
      <li><a href="css1">CSS1</a></li>
      <li><a href="css2">CSS2</a></li>
      <li><a href="css3">CSS3</a></li>
      <li>Basic XPath</li>
    </ul>
  </li>
  <li>jQuery also supports
    <ul>
      <li>Custom selectors</li>
      <li>Form selectors</li>
    </ul>
  </li>
</ul>


E>F         Matches all elements with tag name F that are direct children of E.(匹配tag name 为F,作为E的直接子节点的所有元素)

声明     $("ul>li")

注意     $("ul>a")  这样是错误的; 因为 a 不是 ul 的直接子节点

JQuery CSS 基本选择器 详解

对应Html:

<ul class="myList">
  <li><a href="http://jquery.com">jQuery supports</a>
    <ul>
      <li><a href="css1">CSS1</a></li>
      <li><a href="css2">CSS2</a></li>
      <li><a href="css3">CSS3</a></li>
      <li>Basic XPath</li>
    </ul>
  </li>
  <li>jQuery also supports
    <ul>
      <li>Custom selectors</li>
      <li>Form selectors</li>
    </ul>
  </li>
</ul>


E+F         Matches all elements F immediately preceded by sibling E.(匹配所有紧接在 E 元素后的 F 元素 –-- E和F 紧挨 着

声明         $("label+input") 

注意          必须是闭口的tag 元素(如下Blue 注记处 ), 而且取得是所有的F元素

错误认识    $("div+label")是错误的

               因为对应的Html不是紧挨着的关系子与父的关系

Html        <div><label>Some images:</label></div>


JQuery CSS 基本选择器 详解 

对应的Html:

<div>
    <label>Radio group:</label>
    <input type="radio" name="radioGroup" noshade>

E~F        Matches all elements F preceded by any sibling E. (匹配 E 元素之后的所有 F 元素 –---  E和F可以 不紧挨 着

声明        $("div~button") 

             或 $("div~Tabel")

注意          必须是闭口的tag 元素(如下Blue 注记处 ), 而且取得是所有的F元素

JQuery CSS 基本选择器 详解

对应的Html:

  <div>
    <label>Radio group:</label>
    <input type="radio" name="radioGroup" noshade>

E:has(F)    Matches all elements with tag name E that have at least one descendent with tag name F.

                 (匹配tag name为 E 、至少有一个标签名称为 F 的后代节点的所有元素)

声明        $("div:has(img)")

          $("ul:has(ul)")

注意         有has 就会有 not ;所以表示not的关系可以声明为

              $("div:not(:img)")

Has 图  $("div:has(img)")

JQuery CSS 基本选择器 详解

Not 图  $("div:not(:img)")

JQuery CSS 基本选择器 详解

对应的Html:

<div>
  <img src="images/image.1.jpg" noshade>

E.C        Matches all elements E with class name C. Omitting E is the same as *.C. (匹配带有类名 C 的所有元素 E ,等效为 *.C )

声明        $("ul.myList")

         $("*.myList")

注意        类名就是html的class的属性名或者aspx的CssClass的属性名

JQuery CSS 基本选择器 详解

对应的Html:

<ul class="myList">
  …

</ul>


E#I        Matches element E with id of I. Omitting E is the same as *#I. (匹配id属性值为I的无素E; #I 等效为 *#I)

声明        $("div#someDiv")

JQuery CSS 基本选择器 详解 

对应的Html:

<div >

This is a &lt;div&gt; with an id of <tt>someDiv</tt>

</div>


E[A]        Matches all elements E with attribute A of any value. (匹配带有属性A的所有元素E  -- 不管属性A的值是什么)

声明        $("div[title]")  或 $("Input[Type]")

JQuery CSS 基本选择器 详解 

对应的Html:

<div title="myTitle1"><span>Hello</span></div>
<div title="myTitle2"><span>Goodbye</span></div>


E[A=V]        Matches all elements E with attribute A whose value is exactly V. (匹配所有元素E,其属性A的值为V)

声明              $("input[type=radio]")

JQuery CSS 基本选择器 详解

对应的Html:

    <input type="radio" name="radioGroup" /> C


E[A^=V]        Matches all elements E with attribute A whose value begins with V. (匹配所有元素E,其属性A的值以V开头)

声明                $("input[type^=rad]")

JQuery CSS 基本选择器 详解

对应的Html:

    <input type="radio" name="radioGroup" /> C


E[A$=V] Matches all elements E with attribute A whose value ends with V. (匹配所有元素E,其属性A的值以V结尾)

声明                $("input[type$=ox]") 或  $("a[href$=.pdf]")

JQuery CSS 基本选择器 详解

对应的Html:

<input type="checkbox" name="checkboxes" /> 4


E[A*=V] Matches all elements E with attribute A whose value contains V. (匹配所有元素E,其属性A的值包含V)

声明                $("input[type*=eck]")

JQuery CSS 基本选择器 详解

对应的Html:

<input type="checkbox" name="checkboxes" /> 4

相关文章:

  • 2022-01-28
  • 2021-11-07
  • 2021-12-28
  • 2021-12-28
猜你喜欢
  • 2021-09-16
  • 2022-12-23
  • 2022-02-07
  • 2021-12-28
  • 2022-02-28
  • 2021-11-13
  • 2021-11-17
相关资源
相似解决方案