0
我写了这段代码,当你点击元素上面的元素时,它的大小将会变大或变小JavaScript向下拖动元素。在第一次拖动后跳转
当我点击它时,它似乎很好地拖了一下然后试图拖下来再次导致它从屏幕上掉下来。
function pulldown(element){
var puller = document.getElementById(element);
puller.addEventListener("mousedown", function(e){
var boxStyle = document.getElementById("resizeBox").getAttribute("style");
var currentSize = (boxStyle.match(/\d+/));
var ypos = e.clientY;
var resize = document.getElementById("resizeBox");
resize.style.height = currentSize;
function watchPull(e){
number2 = currentSize + (e.clientY - ypos);
resize.style.height = number2+"px";
}
document.addEventListener("mousemove", watchPull,false);
document.addEventListener("mouseup", function(e){
document.removeEventListener("mousemove", watchPull, false);
number = currentSize + (e.clientY - ypos);
resize.style.height = number+"px";
},false)
},false);
}
pulldown("pullDown");
这是发生了什么事。
http://jsfiddle.net/jamcoupe/4hKg8/ (点击“无项目”,然后拖动黑线向下或向上)
我已经解决了这个我自己,我只是需要等待回答。 http://jsfiddle.net/jamcoupe/4hKg8/1/ – jamcoupe 2012-01-10 02:13:08