how to add class using javascript in div
Posted
by
Fahim Parkar
on Stack Overflow
See other posts from Stack Overflow
or by Fahim Parkar
Published on 2012-12-02T10:58:43Z
Indexed on
2012/12/02
11:03 UTC
Read the original article
Hit count: 216
I have so many modules and I am showing border to each module.
Below is what I have
div.ja-moduletable-inner,
div.moduletable-inner {
background: none;
padding: 1.5em;
box-shadow: 0px 0px 3px 3px rgba(0,0,0,.25);
}
<div id="Mod143">
<div class="moduletable-inner clearfix">
</div>
</div>
<div id="Mod148">
<div class="moduletable-inner clearfix">
</div>
</div>
<div id="Mod149">
<div class="moduletable-inner clearfix">
</div>
</div>
Note : These modules are added by-default by Joomla, so I can't handle this. What I want is using Javascript, I want to add class in Mod149
so that I will have it as
<div id="Mod149">
<div class="moduletable-inner clearfix newMyOwnClass">`
^^^^^^^^^^^^^^
</div>
and I will have in css as
div.newMyOwnClass {
box-shadow: 0px 0px 0px 0px rgba(0,0,0,.25);
^^^^^^^
}
Any idea how to get this done in Javascript?
No jQuery... Only Javascript AND only with div id Mod149
© Stack Overflow or respective owner