Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: Change highlight fade-to color?

Is it possible to change the color that the jQuery highlight effect fade's to?

Right now it starts the highlight at yellow, then fades to white and then fades out.

I ultimately what to highlight the background color with yellow, then just fade to transparent.

like image 802
Shpigford Avatar asked Jun 01 '11 21:06

Shpigford


2 Answers

I've just come across this behavior as well in jQuery UI 1.8.9, it seems to be a bug.

The way around it for me was to define the background color of the element I was highlighting in the CSS instead of letting it default to transparent.

If the background color isn't set (i.e. it is transparent), assuming you haven't changed the highlight color, then it will fade the element to yellow then to white and then fade out.

However, if you set the background color of the element you are highlighting it will fade to yellow then to the element's original color when you highlight it.

like image 174
Ross Avatar answered Nov 13 '22 08:11

Ross


$("#id").effect( "highlight",{color:'#FFFF00',easing:'easeInElastic'},4000 );

In the options object for effect, you can change the default property of color to whatever you want. My element isn't set to a color and it highlights bright yellow, then fades back to nothing. I'm using jQuery 1.8.1 and jQuery-UI.

like image 27
bwinchester Avatar answered Nov 13 '22 09:11

bwinchester