Provided I have two different css files, each containing a definition of the same css class (Eg. .mainDiv {}
) but each class would have different properties, how would I be able to apply them to two different divs in my HTML code (say with ids myMainDiv1
and myMainDiv2
)?
I realize this is no longer an association between div element ids and css classe names but I would like to know if it is possible somehow to parse/read each css file - through JavaScript - and apply the rules dynamically for each of my divs.
So I would in no way want to make changes to the css files; I can have as many as needed but they all need to have the very exact same class names (Eg. mainDiv
); through JavaScript - if possible - I can apply the styles for each of my divs.