I have this html code:
<div class="rotation">
<ul>
<li><img src="..." alt="" /></li>
<li><img src="..." alt="" /></li>
<li><img src="..." alt="" /></li>
</ul>
</div>
I need to add class to ul, i want to do it using jquery, because ul, li are generated without any class.
Let say ul tag need to be <ul class="image_rotation">. How can i do it?
Read about jQuery’s
addClassmethod here.The above code will add a class of
image_rotationto everyulthat is a descendant of any element with the classrotation.If you want to target only
uls that are an immediate child of an element with a class ofrotation, use the child selector (>):If you only want to do this on one
.rotationelement, you should give it an id and select it that way. For example:and