sun sun - 1 year ago 159
jQuery Question

How to change css position left to right using jquery?

I have a div with

left
value i wanted to change it to
right
side with values

#check
{
left:50px;
top:20px;
position:relative;
width:100px;
height:100px;
background:rgb(100,200,0);
}


So i tried jquery like this

$(document).ready(function(){

$('#check').css('right','20px');

});


is this possible?.i tried searching but all are with the same attribute different value changes.
Here is the Fiddle

Answer Source

You have to set left to default, and the value for right:

$(document).ready(function(){

 $('#check').css({
  'right':'20px',
  'left': 'auto'
 });

});

JSfiddle thanks to MackieeE

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download