Html Page 移动图片

发布时间 2023-10-09 06:43:19作者: 物华天宝之藏

html:

<img src=image.jpg id='imageid'   style="position:absolute; left: 0; top: 0;">

js: 

var x=document.getElementById('imageid').offsetTop;
x= x + step;
document.getElementById('imageid').style.top= x + "px";

 

getElementById 有效

document.getElementById('imageid')

  

querySelector 无效:

document.querySelector('img')