ejyoo's 개발 노트

셀렉터(너무 어려웡...) 본문

FrontEnd/HTML, CSS

셀렉터(너무 어려웡...)

ejyoovV 2021. 3. 26. 12:04

www.w3schools.com/jquery/tryit.asp?filename=tryjquery_sel_nthchild

 

Tryit Editor v3.6

$(document).ready(function(){ $("p:nth-child(3)").css("background-color", "yellow"); }); This is a heading in body The first paragraph in body. The second paragraph in body (and the 3rd child element in body). This is a span element in div The first paragr

www.w3schools.com

$(document).ready(function(){
  $("div p:nth-of-type(2)").css("background-color", "yellow");
});

 

 

www.w3schools.com/jquery/sel_nthchild.asp

 

jQuery :nth-child() Selector

jQuery :nth-child() Selector ❮ jQuery Selectors Example Select each

element that is the third child of its parent: $("p:nth-child(3)") Try it Yourself » Definition and Usage The :nth-child(n) selector selects all elements that are the nth child, reg

www.w3schools.com

$(document).ready(function(){
  $("p:nth-child(3)").css("background-color", "yellow");
});