开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜