css - How to Find and replace class with javascript (No JQ) -
for example: have <div class="oneclass twoclass colorred">content</div>
, want find color*
class , replace color part "red" new value "blue" or "yellow" example "colorblue
" now...
how do javascript ?
thanks!
update: isn't question: change element's class javascript
var node = document.getelementbyid('somediv'); node.classname = node.classname.replace(/color.*/, 'colorblue');
/* css snippet allow see * element's classes rendered html ;)*/ div:after { content: attr(class); margin-left: 5px; font-style: italic; color: gray; }
<div id="somediv" class="oneclass twoclass colorred">content</div>
Comments
Post a Comment