Example HTML:
<div id="foo" class="class_one"></div>
How can I add the class class_two
without replacing class_one
?
end result:
<div id="foo" class="class_one class_two"></div>
See deekshith's answer below if you only need to support new browsers
Standard javascript:
document.getElementById('foo').className += ' class_two'
or JQuery:
$('#foo').addClass('class_two');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With