0

In jQuery I have section where onclick it changes some properties. I was wondering if i could include css transitions into this somehow. I tried to add it in just like I did but that just gave it a property it didn't effect it when it does change.

$("#slide1-1").click(function() {
$('.aboutchange').css('color', '#433792');
});

$("#slide1-2").click(function() {
$('.aboutchange').css('color', 'orange');
});

$("#slide1-3").click(function() {
$('.aboutchange').css('color', 'green');
});

$("#slide1-4").click(function() {
$('.aboutchange').css('color', 'red');
});
1
  • sorry everyone I figured this out by simply adding css transition to the class. Commented Apr 24, 2012 at 2:05

2 Answers 2

2

You need to use jQuery's animate function for transitions. this will animate to your text color of choice over a period of 1000 milliseconds. jQuery UI gives lots of bonus effects as well.

$("#slide1-1").click(function() {
    $('.aboutchange').animate({ color:'#433792' }, 1000);
});

edit

maybe I didn't understand the question and that's why I got downvoted... if you are trying to use css3 transitions then you should be declaring the transitions and states in css and using .addClass() and .removeClass() to add/remove the appropriate states and transitions

Sign up to request clarification or add additional context in comments.

Comments

2

jQuery doesn't provide color animations by default. You need to use jQuery UI which comes with the jquery-color plugin, or you can just use jquery-color. Then you can animate like any other property:

$element.animate({ color: 'blue' });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.