1st div element, 4th div element
last div, and for even and odd div elemets also.
one by one?
apply the red color on the above div.
<div class="questions">
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
</div>
Code for first div : $("div.questions > div:first").css("color", "green");
Code for 4th div : $("div.questions > div:nth-child(4)").css("color", "green");
Code for last div : $("div.questions > div:last").css("color", "green");
Code for even div : $("div.questions > div:even").css("color", "green");
Code for odd div : $("div.questions > div:odd").css("color", "green");
last div, and for even and odd div elemets also.
one by one?
apply the red color on the above div.
<div class="questions">
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
<div class="box"> Question</div>
</div>
Code for first div : $("div.questions > div:first").css("color", "green");
Code for 4th div : $("div.questions > div:nth-child(4)").css("color", "green");
Code for last div : $("div.questions > div:last").css("color", "green");
Code for even div : $("div.questions > div:even").css("color", "green");
Code for odd div : $("div.questions > div:odd").css("color", "green");
No comments:
Post a Comment