[英]how to implement mousemove after mousedown using js
我需要实现一个mouse over
后, mouse down
,这样当用户按下并移动将要打开电池(扫雷舰)
这是我的代码!
case 2:
{
if ($(this).hasClass("open") || $(this).hasClass("bomb") || $(this).hasClass("close")) {
var X_axis;
var Y_axis;
$('.close').mousemove(function (event2) {
if ($(this).attr('row') != X_axis && $(this).attr('column') != Y_axis) {
var obj = $("[row='" + X_axis + "'][column='" + Y_axis + "']");
$(obj).addClass("close");
}
$(this).removeClass("close");
X_axis = $(this).attr('row');
Y_axis = $(this).attr('column');
});
}
}
break;
case 2 --> mean left mouse click
哦,抱歉,这是解决方案
if ($(this).attr('row') != X_axis || $(this).attr('column') != Y_axis)
使用|| 不是&&,因为数组2d以及当前单元格x_axis可能等于先前的单元格x_axis...。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.