I’m writing a cool jQuery snippet where I will need to get the value of the background color and font color from an element’s style rules.
I tried this and it’s not doing anything: var CSSbackground = $(‘.submit-btn’).css(‘background’);
I just want to get the current values so I can manipulate it dynamically. (Ultimate is to invert them on hover). I know how to accomplish the rest; but getting the current values is stumping me (Yes, I have been googling all morning).
That’s actually not true, it returns the computed styles. @marianstevens what do you mean with it’s not doing anything? What is the exact value of CSSbackground when you log it to the console?
I revisited my jsfiddle and got it to return the values in rgb…I’d rather it return the colors in hex, not sure how to do this quite yet. Here’s a link to my fiddle:
Okay I have gotten that part to work - I am not sure how to select the pseudo hover class. The idea of this whole thing is to invert the font and background colors on the hover event. (I thought I had this). What direction should I be going in?