2017-6-2 jQuery 基礎 選取器

來源:互聯網
上載者:User

標籤:doctype   meta   color   title   font   jquery   round   bsp   技術分享   

用代碼練習:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <script src="js/jquery-1.7.1.min.js"></script><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <title></title>    <style type="text/css">        .div1         {            width:100px;            height:100px;            background-color:red;            float:left;            margin-left:20px;        }        #d1         {            background-color:green;        }         .div2        {            width:100px;            height:100px;            background-color:blue;            float:left;            margin-left:20px;        }            .div3        {            width:50px;            height:50px;            background-color:blue;            float:left;            margin-left:20px;        }    </style></head><body>    <form id="form1" runat="server">    <div class="div1">11111        <div class="div3"></div>    </div>    <div class="div1" id="d1"> 2222</div>        <div class="div1" id="d2"> 3333</div>        <div class="div1"> 444441</div>   <div class="div2"> 555552</div>    </form></body></html><script type="text/javascript">    //ID選取器    //$("#d1").click(function () {    //    alert("aa");    //});    //class選取器    //$(".div1").click(function () {    //    alert("aa");    //    alert($(this).index());    //});    //標籤選取器    //$("div").click(function () {    //    alert("11");    //});    //並欄選取器    //$(".div1,.div2").click(function () {    //    alert("bb");    //});    //後代選取器    //$(".div1 .div3").click(function () {    //    alert("cc");    //});    //過濾選取器    //首:    //$(".div1:first").click(function () {    //    alert("這是第一個");    //});    //尾:    //$(".div1:last").click(function () {    //    alert("這是最後一個");    //});    //等於:    //$(".div1:eq(2)").click(function () {    //    alert("這是第三個");    //});    //$(".div1").eq(2).click(function () {    //    alert("這是第三個");    //});    ////大於:    //$(".div1:gt(0)").click(function () {    //    alert("aa");    //});    ////小於:    //$(".div1:lt(3)").click(function () {    //    alert("aa");    //});    ////排除:not(選取器)    //$(".div1:not(.div1:eq(2))").click(function () {    //    alert("aa");    //});    ////奇數:    //$(".div1:odd").click(function () {    //    alert("aa");    //});    ////偶數:    //$(".div1:even").click(function () {    //    alert("aa");    //});    ////屬性名稱過濾:    //$(".div1[id]").click(function () {    //    alert("aa");    //});    ////屬性名稱等於或者非等於值的過濾:    //$(".div1[id=d1]").click(function () {    //    alert("aa");    //});    //$(".div1[id!=d1]").click(function () {    //    alert("aa");    //});    //包含字串的過濾:    $(".div1:contains(‘1‘)").click(function () {        alert("aa");    });</script>

 

2017-6-2 jQuery 基礎 選取器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.