Adding class to existing html id using purely javascript -
so have div id no class so...
<div id="leftgrapharea" style="float:left; width:100%;height:90%;border:0px solid blue;"> left graphing area </div>
what add classes id using javascript. know can add classes div id in html typing in can't because have code creates graphs , there no real limit how many graphs can made. basically, codes in javascript result in same html code below.
<div class="graph" draggable="true"><header>a</header></div> <div class="graph" draggable="true"><header>b</header></div> <div class="graph" draggable="true"><header>c</header></div>
i'd appreciate if me this. in advance.
you can use classlist
document.getelementbyid('leftgrapharea').classlist.add('graph');
or classname
document.getelementbyid('leftgrapharea').classname += ' graph';
Comments
Post a Comment