jQuery --- basic selectors

 

The basic selector

name usage description
ID selector $(“#id”); Gets the element specified ID
Class selector $(“.class”); Getting an element of the same type of class
Tag selector $(“div”); Get all elements of the same class label
And set selector $ ( "Div, p, it"); Use commas to separate, it meets one of the conditions can be.
Intersection selector $(“div.redClass”); Get the class to the div element redClass

Summary: use css selector with exactly the same.

 

$ ( "S1, S2") // and diversity selector 
$ ( "S1 S2") // descendant selector 
$ ( "S1> S2") // progeny selector 
$ ( "S1S2") // intersection selection is 
$ ( "li.green") // intersection selector

 

 

      //id选择器  $("#id")
      $("#four").css("backgroundColor", "black");

 

      // class style selector $ (. "ClassName") 
      $ (. "Green") CSS ( "backgroundColor", "Green").;

 

      // tag selector $ ( "li") 
      $ ( "li") CSS ( "Color", "Red").;

 

      //并集
      $("#four,.green").css("backgroundColor", "pink");

 

// intersection
 $("li.green").css("backgroundColor", "red"); $(".green.yellow").css("backgroundColor", "pink");

 

 

Guess you like

Origin www.cnblogs.com/jane-panyiyun/p/12196540.html
Recommended