Add Class using jQuery
My Html mark-up is somthing like this
<div>
<div></div>
<div></div>
<div></div>
<div class="last">
<div class="a">
<div class="b">
<div class="c"></div>
</div>
</div>
</div>
</div>
Want to add a extra class in <div class="last">
,<div class="a">
,<div class="b">
, and <div class="c">
. 开发者_开发百科Using jQuery
$('div:last').addClass('yourclass');
See Demo Here :)
Last div:
$('div.last').addClass('class');
Last div of the last div:
$('div.last').find('div:last').addClass('class');
See more info about:
addClass
:last
精彩评论