第一种写法
document.getElementById('xx').onmousedown = function(){
document.onmousemove = function(){
}
}第二种写法
document.getElementById('xx').onmousedown = function(){
}
document.getElementById('xx').onmousemove = function(){
}请问这两个不仅从写法不一样,他的表达意思一样吗???
document.getElementById('xx').onmousedown = function(){
document.onmousemove = function(){
}
}第二种写法
document.getElementById('xx').onmousedown = function(){
}
document.getElementById('xx').onmousemove = function(){
}请问这两个不仅从写法不一样,他的表达意思一样吗???
document.getElementById('xx').onmousedown = function(){
document.onmousemove = function(){
}
}第二种写法
document.getElementById('xx').onmousedown = function(){
document.getElementById('xx').onmousemove = function(){
}
}请问这两种写法最终实现的效果一样吗?
document.getElementById('xx').onmousedown = function(){
[color=#FF0000] [color=#FF0000]document.onmousemove = function(){ ---> 这样写跟地下有什么区别[/color] }[/color]
}第二种写法
document.getElementById('xx').onmousedown = function(){
document.getElementById('xx').onmousemove = function(){
}--->跟上面有上面区别
}请大家能够就说的详细一点吗?
document.getElementById('xx').onmousedown = function(){
document.onmousemove = function(){ ---> 这样写跟地下有什么区别
}第二种写法
document.getElementById('xx').onmousedown = function(){
document.getElementById('xx').onmousemove = function(){
}--->跟上面有上面区别
}请大家能够就说的详细一点吗?
第一种写法,快速去拖动一个对象,对象始终跟随鼠标,不存在脱离
document.getElementById('xx').onmousedown = function(){
document.onmousemove = function(){ ---> 这样写跟地下有什么区别
}}第二种写法,也能拖动对象,但是必需慢慢拖动,快速去拖动一个对象,对象马上跟鼠标脱离
document.getElementById('xx').onmousedown = function(){
document.getElementById('xx').onmousemove = function(){
}--->跟上面有上面区别}第三种写法,也能拖动对象,但是必需慢慢拖动,快速去拖动一个对象,对象马上跟鼠标脱离
document.getElementById('xx').onmousedown = function(){
}
document.getElementById('xx').onmousemove = function(){
}--->跟上面有上面区别请大家能够就说的详细一点吗?
mousemove事件不会触发。(mousemove事件触发的条件是,鼠标在对象上,并且有移动。注:这里先不考虑事件冒泡)所以针对这个问题 才有了你写的第一种方案,即在document上注册mousemove事件,因为mousemove事件触发的条件都具备。
第一种写法弹出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;
var moveTop = 0;
title1_tr.onmousedown = function(evt){
moveLeft = parseInt(div_2.style.left);
moveTop = parseInt(div_2.style.top);
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,这是为什么???
第一种写法弹出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,这是为什么???