Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we write multiple css style in single line in JQuery

Tags:

jquery

css

Can we write multiple css style in single line in JQuery

       $('.ui-dialog').css("left","475px");
       $('.ui-dialog').css("top","215px");

Does we can write this to single line like below

       $('.ui-dialog').css("'left','475px'","'top','215px'"); // Test
like image 508
Justin John Avatar asked Nov 29 '11 06:11

Justin John


2 Answers

Yes you can. The jQuery .css() method also accepts a map. Check their documentation for more examples.

$('.ui-dialog').css({
    'left' : '475px', 
    'top' : '215px'
});
like image 111
icirellik Avatar answered Oct 22 '22 13:10

icirellik


You can pass an object with the key as the property and the value as what you may expect.

$('.ui-dialog').css({
  left: 475,
  top: 215
});
like image 23
alex Avatar answered Oct 22 '22 15:10

alex