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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -