开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜