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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -