Reputation: 242
When i tried to animate a div , its shows some error on the line shown below.
Here is the code..Is there any syntax error in this
$("#viewport").animate({margin-left:'50px'},"slow");
Thanks in advance.
Upvotes: 0
Views: 86
Reputation: 6156
$("#your_div").animate({marginLeft: '50px'}, 500);
In your case
$("#viewport").animate({'margin-left':'50px'},"slow");
Upvotes: 0
Reputation: 7181
You cannot have the -
character in Javascript property literals (properties without quotes). jQuery offers a solution for this by converting camelCased names that reference CSS properties to dashed names. So you should change your animate object to {marginLeft: '50px'}
or quote the property name like {'margin-left': '50px'}
.
Upvotes: 3