So the case is like this...
I have an HTML element with a specific css class. I would like to change the value of the property of that specific class without any change to the HTML element itself.
HTML code:
<style>
.someClass{
background-color:red;
}
span .someOtherClass {
background-color:blue;
}
</style>
<span class="someClass someOtherClass">some text</span>
I'm looking for a JS code that will make it so that the ".someClass" identifier will have "background-color:green";
The reason I would like to change the class itself and not just using .css option is that .css changes the style property of the HTML element (inline). The use case is where the second class (someOtherClass) is added and removed dynamically to and from the span element. Using the .css for changing the element with ".someClass" class will change the inline style of the element reasulting with:
<span class="someClass someOtherClass" style="background-color:green;">some text</span>
and this means that adding and removing "someOtherClass" from the span element will not have any affect.
I did think about removing someClass from the span element and replacing it with some new dynamically created class with "background-color:green" but I was wondering if there is something more elegant.
Any assistance will be appreciated.