michaelmcgurk michaelmcgurk - 1 year ago 73
HTML Question

Add class to existing HTML via jQuery

I have this HTML:

<div id='gallery-1' class='gallery galleryid-73 gallery-columns-0 gallery-size-thumbnail'>
<div class='gallery-item'>
<span class='gallery-icon landscape'>
<img width="300" height="200" src="http://placehold.it/400x300" class="attachment-thumbnail size-thumbnail" alt="Aurore, Watercolour" aria-describedby="gallery-1-205" />

I'd like to add a class alongside

How do I do this with jQuery?

Answer Source

Use jquery addclass method

Select the <div class='gallery-item'> with class selector

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download