Question

I am wanting to change the color of the stars on this page using js edit:link is now dead

It is the :before on the class "star-rating" that is controlling the color but I have not been able to successfully change it, possibly because it has an important on it.

I read this but it didn't help Javascript set CSS :after styles

Thanks

Alex

Was it helpful?

Solution

Probably not the nicest way to do it, but

s = document.createElement('style') ; 
s.innerHTML = '.star-rating span:before, .star-rating:before, .woocommerce-page .star-rating:before { color:pink !important}' ; 
document.head.appendChild(s); 

i.e. add a style tag to the head which overrides the style for those stars.

OTHER TIPS

The only solution is to remove and add new DOM for that stars or you can remove that !important from css and then change by using JS.

Otherwise use jquery and then :

starDiv = document.getElementsByClassName("star-rating")[0];
$(starDiv).css('color', 'red', 'important');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top