1

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

Community
  • 1
  • 1
Alex
  • 1,060
  • 2
  • 17
  • 35
  • why you need js? it can be done only with css – DaniP Dec 05 '13 at 14:03
  • I only want it to happen on certain pages, and I didn't make the theme so would rather stay out of the css files – Alex Dec 05 '13 at 14:04
  • so you can create your own stylesheet or put it on the head of the pages you want are you searching a solution for pure js or jquery too? – DaniP Dec 05 '13 at 14:05
  • the pages are dynamically created by a plugin in Wordpress, js is the only way I can achieve what I want to do – Alex Dec 05 '13 at 14:07

2 Answers2

1

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.

towr
  • 4,147
  • 3
  • 20
  • 30
0

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');
Nish
  • 325
  • 2
  • 3
  • 11