请教一个关于javascript的作用域问题
Re请教一个关于javascript的作用域问题
嗯,用函数包起来
(function(){ var started = false; var startX, startY; function doMouseDown(event) { startX = event.pageX; startY = event.pageY; started = true; } var c = document.getElementById('s'); c.addEventListener('mousedown', doMouseDown, false);})();
赞0
踩0