jQuery增強型基本選擇器

:first:查詢第一個元素
:last:查詢最后個元素
:checked:查詢選中的復(fù)選框
:not(:checked):查詢未選中的復(fù)選框
:even:偶數(shù)
:odd:奇數(shù)
:eq():索引從0開始
:gt():大于索引號
:lt():小于索引號
:header:查詢所有<h2/2/3/4/5/6>標(biāo)簽
.css("key","value")為查詢到的所有標(biāo)簽添加CSS樣式

成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供安居網(wǎng)站建設(shè)、安居做網(wǎng)站、安居網(wǎng)站設(shè)計、安居網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、安居企業(yè)網(wǎng)站模板建站服務(wù),十年安居做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="../js/jquery-1.6.js"></script>
  </head>
  <body>
    <ul>
        <li>list item 1</li>
        <li>list item 2</li>
        <li>list item 3</li>
        <li>list item 4</li>
        <li>list item 5</li>
    </ul>
    <input type="checkbox" checked/>
    <input type="checkbox" checked/>
    <input type="checkbox"/>
    <table border="1">
      <tr><td>line1</td></tr>
      <tr><td>line2</td></tr>
      <tr><td>line3</td></tr>
    </table>    
    <h2>h2</h2>
    <h3>h3</h3>
    <h4>h4</h4>
    <p>p</p>
    <script type="text/javascript">

        //1)查找UL中第一個元素的內(nèi)容
        // alert($("ul li:first").html());
        // alert($("ul>li:first").html());

        //2)查找UL中最后個元素的內(nèi)容
        // alert($("ul>li:last").html());

        //3)查找所有未選中的input元素個數(shù)
        //alert($("input:not(:checked)").size());
        //alert($("input:checked").size())

        //4)查找表格的1、3、5...奇數(shù)行個數(shù)[從0開始計數(shù)]
        //alert($("table tr:even").size());

        //5)查找表格的2、4、6...偶數(shù)行個數(shù)[從0開始計數(shù)]
        //alert($("table tr:odd").size());

        //6)查找表格中第二行的內(nèi)容,從索引號0開始
        //alert($("table tr:eq(1)").html());

        //7)查找表格中第二第三行的個數(shù),即索引值是1和2,也就是比0大
        //alert($("table tr:gt(0)").size());

        //8)查找表格中第一第二行的個數(shù),即索引值是0和1,也就是比2小
        //alert($("table tr:lt(2)").size());

        //9)給頁面內(nèi)所有標(biāo)題<h2><h3><h4>加上紅色背景色
        $(":header").css("background","red");

    </script>
  </body>
</html>

分享標(biāo)題:jQuery增強型基本選擇器
本文網(wǎng)址:http://bm7419.com/article26/gipgjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、網(wǎng)站維護、標(biāo)簽優(yōu)化、網(wǎng)頁設(shè)計公司、虛擬主機、建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)