2017-6-2 JQuery Base Selector

Source: Internet
Author: User

Practice with Code:

<%@ Page language="C #"autoeventwireup="true"codefile="Default.aspx.cs"inherits="_default"%><! DOCTYPE html>"http://www.w3.org/1999/xhtml">"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>"Form1"runat="Server"> <divclass="Div1">11111<divclass="Div3"></div> </div> <divclass="Div1"Id="D1">2222</div> <divclass="Div1"Id="D2">3333</div> <divclass="Div1">444441</div> <divclass="Div2">555552</div> </form></body>"Text/javascript">//ID Selector//$ ("#d1"). Click (function () {//alert ("AA"); //}); //class Selector//$ (". Div1"). Click (function () {//alert ("AA"); //alert (This). index ()); //}); //Tag Selector//$ ("div"). Click (function () {//alert ("11"); //}); //Parallel Selector//$ (". Div1,.div2"). Click (function () {//alert ("BB"); //}); //descendant Selector//$ (". Div1. Div3"). Click (function () {//alert ("CC"); //}); //Filter Selector//First://$ (". Div1:first"). Click (function () {//alert ("This is the first one"); //}); //Tail://$ (". Div1:last"). Click (function () {//alert ("This is the last one"); //}); //equals://$ (". Div1:eq (2)"). Click (function () {//alert ("This is the third one"); //}); //$ (". Div1"). EQ (2). Click (function () {//alert ("This is the third one"); //});    ////Greater:    //$ (". DIV1:GT (0)"). Click (function () {//alert ("AA"); //});    ////Less:    //$ (". DIV1:LT (3)"). Click (function () {//alert ("AA"); //});    ////exclude: Not (selector)    //$ (". Div1:not (. Div1:eq (2))"). Click (function () {//alert ("AA"); //});    ////Odd:    //$ (". Div1:odd"). Click (function () {//alert ("AA"); //});    ////even:    //$ (". Div1:even"). Click (function () {//alert ("AA"); //});    ////attribute name filtering:    //$ (". Div1[id]"). Click (function () {//alert ("AA"); //});    ////attribute name is equal to or not equal to the value of the filter:    //$ (". Div1[id=d1]"). Click (function () {//alert ("AA"); //}); //$ (". Div1[id!=d1]"). Click (function () {//alert ("AA"); //}); //filter that contains the string:$(". Div1:contains (' 1 ')"). Click (function () {alert ("AA"); });</script>

2017-6-2 JQuery Base Selector

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.