Applying CSS in JavaScript indirectly -
when write real css do
.blue { color: blue; }
and if added class "blue" element after loading, turn blue.
in javascript have like
var blue = document.getelementsbyclassname('blue'); (var = 0; < blue.length; i++) blue[i].style.setproperty('color', 'blue');
the problem javascript version if did
document.getelementbyid('someid').classname += " blue";
it have class blue, not turn blue. there way (preferably simple) add style selector rather directly elements selector?
see this question. can add <style>
element via javascript.
Comments
Post a Comment