I would like my text to fade from white to black and the background colour to change from black to white simultaneously any ideas?
A:
In jQuery you can animate the colour of text by default using:
$('#element').animate({
color: 'red'
}, 1500);
But background animations cannot be done by default and require a plugin (links below).
jQuery: http://www.jquery.com/
Colour plugin: http://plugins.jquery.com/project/color
Enjoi ^.^
Neurofluxation
2010-09-04 08:36:18
A:
This could be achieved easily with the jQuery color plugin:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.color.js"></script>
<script type="text/javascript">
$(function() {
$('#foo').animate({
backgroundColor: '#fff',
color: '#000'
}, 'slow');
});
</script>
</head>
<body>
<div id="foo" style="background-color: black;">Some Text</div>
</body>
</html>
See it in action here.
Darin Dimitrov
2010-09-04 08:42:57
can i do this with set timeout?
Sam
2010-09-04 09:04:12
Sure, you can: http://jsfiddle.net/4p5ZG/1/
Darin Dimitrov
2010-09-04 09:08:16
is it possible to use ur method if the div is in another function that creates some text say a paragraph and the body is just <body id=body>???
Sam
2010-09-04 11:34:16
@Sam, I don't understand your question, a DIV is into the DOM, how can it be in another function?
Darin Dimitrov
2010-09-04 11:41:16
no sorry i ment can i put the div into the script instead of body
Sam
2010-09-05 03:49:13