Why is the object not moving on clicking the button?

后端 未结 3 1016
我在风中等你
我在风中等你 2021-01-28 17:27

The object is not moving on clicking the button. Why is it so?

<
3条回答
  •  离开以前
    2021-01-28 17:36

    You would need to include the styling at the end of the statement

    function animate() {
      var x = 100;
      var object = document.getElementById('object').style.left = x + 'px';
    }
    #object {
      position: absolute;
      top: 50px;
      right: 20px;
      left: 20px;
      height: 40px;
      width: 80px;
      background-color: green;
    }

提交回复
热议问题