Div is not moving
开发者_如何学GoI am trying to move div
's position but it is not moving. Any idea?
$(document).ready(function()
{
$("#btn1").click(function(){
$("#box").attr("left","300px");
});
});
You can try this
$(document).ready(function()
{
$("#btn1").click(function(){
$("#box").css("position", "relative");
$("#box").css("left","300px");
});
});
</script>
simple answer: $('#box').css({'left' : '300px'});
Also make sure your position
is set to either absolute
, relative
or fixed
.
The div
is probably position: static
.
It needs to be one of
position: relative
position: absolute
position: fixed
for left
to have any effect.
精彩评论