Reputation: 239
Is there an easy way to make multiple changes to the css in jQuery without the extra lines of code? i.e. I have a function:
$(function() {
$('h1[id=300]').click(function(){
$('#box').css('background','orange');
$('#box').animate({
"left" : "300px"
});
});
});
Let's say I want to change the div box size. How would I add it within the changes that are already being applied to background color above?
Thanks
Upvotes: 1
Views: 81
Reputation: 1261
You can do something like this:
$("#box").css({
background:'orange',
left:'300'
});
(where background and left are your styles)
Upvotes: 0
Reputation: 117324
Use a object where you define the styles as argument for css() , e.g.:
$('#box').css({'background':'orange',
'width':'200px',
height:'100px'});
Upvotes: 3