If I have css:
.myclass
{
background: #FF00FF;
}
And html:
etc.
Here you go:
[].every.call( document.styleSheets, function ( sheet ) {
return [].every.call( sheet.cssRules, function ( rule ) {
if ( rule.selectorText === '.myclass' ) {
rule.style.backgroundColor = 'green';
return false;
}
return true;
});
});
Live demo: http://jsfiddle.net/gHXbq/
ES5-shim for IE8
Hope I am close to what you are expecting when I say You may please try something like this:-
$(document).ready(function(){
$("button").click(function(){
$("div").toggleClass("myclass");
});
});
.myclass
{
background: #FF00FF;
}
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<button>Set the color property of all p elements</button>
<div class="myclass">etc.</div>
<div class="myotherclass">etc.</div>
<div class="myclass">etc.</div>
</body>
</html>