document.getElementsByClassName('myclass');
will return an array of elements which match.
You could also use something along the lines of:
<body>
<div id="changethese">
<div class="myclass" onclick="change_class()">Some Text</div>
</div>
<div class="myclass">div two</div>
</body>
Javascript:
var changeTheseDivs = document.getElementById('changethese');
changeTheseDivs.getElementsByClassName('myclass')
To change only the class within the selected div.
However, support for this method only works back to IE9, so if JQuery is an option, it might be best to use that.
Edit:
I believe I misread, it looks like you want to change the actual CSS rule itself as opposed to changing CSS on the elements. You could, in theory, write a function that will find rules by name for you and change their properties. I guess it would look something like this (untested, should work):
function findAndChangeCSSRule(ruleName, newRule, newProperty){
var mysheet=document.styleSheets[0];
var myrules=mysheet.cssRules? mysheet.cssRules: mysheet.rules
for (i=0; i<myrules.length; i++){
if(myrules[i].selectorText.toLowerCase()==ruleName){
targetrule=myrules[i];
break;
}
}
targetrule.style[newRule.toString()]=newProperty;
}
then call it with:
findAndChangeCSSRule('my_class', 'color', 'red')