Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade a class in?

Tags:

jquery

I've got a <td>. It has a class applied which specifies a background color. Can I fade-in to a different class, which just has a different background color? Something like:

// css
.class1 {
  background-color: red;
}

.class2 {
  background-color: green;
}

$('#mytd').addClass('green'); // <- animate this?

Thanks

like image 824
user291701 Avatar asked Oct 08 '10 22:10

user291701


People also ask

How do I fade something in Javascript?

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

What is fade in animation?

In android, Fade In and Fade Out animations are used to change the appearance and behavior of the objects over a particular interval of time. The Fade In and Fade Out animations will provide a better look and feel for our applications.


1 Answers

jQueryUI extends the animate class for this reason specifically. You can leave off the original parameter to append a new class to your object.

$(".class1").switchClass("", "class2", 1000);

Sample here.

like image 101
Alexis Abril Avatar answered Sep 26 '22 09:09

Alexis Abril