默认div_2.style.left=200px;
第一种写法弹出200
var moveLeft = parseInt(div_2.style.left);
var moveTop = parseInt(div_2.style.top);
title1_tr.onmousedown = function(evt){
  alert(moveLeft);
}
document.onmousemove=function(evt){
  var evt = evt ? evt : window.event;
  var left = evt.clientX;   
  div_2.style.left = left+'px';
}第二种写法弹出500(假设对象被移动后的left=500)
var moveLeft = 0;
title1_tr.onmousedown = function(evt){
  moveLeft = parseInt(div_2.style.left);
alert(moveLeft);

}
document.onmousemove=function(evt){
  var evt = evt ? evt : window.event;
  var left = evt.clientX;   
  div_2.style.left = left+'px';
}
两种写法弹出值为什么不一样?
像第二种写法,把moveLeft = parseInt(div_2.style.left);
放在onmousedown事件里面,弹出500(对象移动之后)!
假如在第二种写法的时候,把moveLeft = parseInt(div_2.style.left);放在onmousedown事件之外,跟第一种写法差不多,那么弹出值还是等于默认值200,这是为什么???
 

解决方案 »

  1.   

    获取DIV的高度用  offsetHeight  
    不是 div.style.top去看看 scrollHeight offsetHeight clientHeight 。
      

  2.   


    为什么不回答你的问题://1.版式不美观;
    //2.问题表意不明,懒得陪你猜题意;
    //3.帖子没有特色;
    //4.浪费别人的眼球,凭什么帮你;
    //5.csdn本来就不怎么好;
      

  3.   

    谢谢大家的关注!
    问题以解决……对不住,大家了!CSdn的兄弟姐妹们,谢谢你们的关注!