Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade the background-color of a span tag with JQuery

Tags:

I'm trying to fade the background-color of a span tag using JQuery to emphasize when a change has occured. I was thinking the code would be someting like the following inside the click handler, but I can't seem to get it working. Can you show me where I went wrong? Thanks Russ.

$("span").fadeOut("slow").css("background-color").val("FFFF99"); 

That's better, but now it fades both the background-color of the span tag and the text value of the span tag too. I'm trying to just fade the background-color and leave the text visible. Can that be done?

like image 962
Russ Clark Avatar asked Apr 09 '09 12:04

Russ Clark


People also ask

How to change span background color in JQuery?

jQuery code to set the background color of all span elements to blue? A. $(“span”). style(“background-color”,”blue”);

How to make text fade in JQuery?

The jQuery fadeIn() method is used to fade in a hidden element. Syntax: $(selector). fadeIn(speed,callback);

How to fade image in JQuery?

fadeIn() function fades in our first image in 1500 milliseconds (or, 1.5 seconds). The . delay() function acts as a counter and waits 3500 milliseconds (or, 3.5 seconds), then the . fadeOut() function fades it out in 1500 milliseconds (or, 1.5 seconds).


1 Answers

It can be done with the color animation plugin. You'd then do something like

$('span').animate({'backgroundColor' : '#ffff99'}); 
like image 132
mishac Avatar answered Oct 07 '22 16:10

mishac