2

While implementing jquery .animate(), I've to write like

$('#clickme').click(function() {
  $('#book').animate({
    width: '200px',
    height: '500px'
  })
})

Isn't there some way to write the css properties in a css file and just do the 'animate' by including the css property??

Something like

.move{
    width: '200px',
    height: '500px'
}

Then

$('#book').animate({
    // include the .move css class somehow 
})

I tried using $( "#effect" ).addClass( "newClass", 1000 ); but there is no animation, the properties just seem to be assigned after the duration declared!!

2 Answers 2

4

The jQuery UI project extends the addClass method to allow exactly what you're looking for.

jQuery UI - addClass.

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

3 Comments

I tried that but I see not eased animation. The properties just seem to be assigned after the duration I declared.
@ptamzz: This requires you to include the jQuery UI library in addition to jQuery.
It's already there. If it should be animated by using addClass(), then something's wrong in my codes.
2

Don't know if you can switch a complete stylesheet, but you can switch class with this plugin

http://jqueryui.com/docs/switchClass/

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.