I am looking for a way to dynamically change the value of an attribute in a CSS class.
Here is my situation:
I have multiple elements that are all using the same class. Instead of individually selecting and applying styles to each one, I want to alter a specific attribute within the class that is already being used. For example:
.prodName {
max-width: 270px;
display: block;
}
This class is applied to many elements, and I would like to modify one of its attributes like so:
.prodName {
max-width: 350px <---
display: block;
}
Is there a simple method to achieve this using JavaScript?
I have already searched for a solution before posting this question, but haven't found anything straightforward and helpful. Thank you in advance for any assistance provided.