js 注意

1.如果想要动态加清除浮动的代码,可以这样做:

document.getElementById("mainBody").innerHTML += "<div style=‘clear:both;‘/>";


2.JS 获取元素DIV属性 offsetTop offsetLeft offsetWidth offsetHeight VALUE值

需要注意的地方有:

1. 设置DIV元素的position 属性, 如position: absolute;
2. dispaly属性不应该为null, 否则得到的值总是0;
原文地址:https://www.cnblogs.com/Yogurshine/p/7077848.html