ptamzz
ptamzz

Reputation: 9355

declaring css properties in a css file for jquery .animate()

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!!

Upvotes: 2

Views: 191

Answers (2)

ecchymose
ecchymose

Reputation: 673

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

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

Upvotes: 2

lonesomeday
lonesomeday

Reputation: 237845

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

jQuery UI - addClass.

Upvotes: 4

Related Questions