tags:

views:

76

answers:

1

I have a paragragh of text.

<p>
line1
line2
line3
</p>

intially all the text are red when a button is pressed each line's color changes to black gradually (2 sec each line)

can this be done with only jquery?

+2  A: 

Yes it can be done with jQuery but you will need the Color Animation plugin...

http://plugins.jquery.com/project/color

EDIT: Sorry mate this script should do it for you (you will need the color plugin still)

// Rename #go to the trigger that starts the animation
$("#go").click(function(){
var i = -1;
// Rename #container to the name of the element surrounding the p tags
var arr = $("#container p");
(function(){
if(arr[++i])
$(arr[i]).animate({ color: "#ff0000" }, 2000, "linear", arguments.callee)
})();
});
Kane Wallmann
ok great. need a little help with the timer part
I've updated my answer to include an example script
Kane Wallmann
thanks you for your help
it changes all lines at the same time. how can i change the color one line at a time?
nevermind. my mistake.