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