单击并按住事件 Javascript
Click and hold event Javascript
我还没有开始我将要从事的项目,但在规划过程中我无法解决点击并按住事件问题。
我将点击 div(图像元素上方的 div,但我仍然可以点击图像),不透明度约为 0.7,它下面的图像。我将能够单击图像并在 canvas 上移动它(基本上只是将它从 canvas 的一侧移动到另一侧)。
有谁知道创建点击并按住事件的方法,当我点击图像将其移动到 canvas 时,点击 divs 不透明度变为 0(或者 div 一起隐藏),然后当我取消单击时它又回到 0.7?
谢谢!
jQuery 的 https://api.jquery.com/mousemove/ 呢?
在文档中,他们有一个示例如何将 even 绑定到目标:
$( "#target" ).mousemove(function( event ) {
var msg = "Handler for .mousemove() called at ";
msg += event.pageX + ", " + event.pageY;
$( "#log" ).append( "<div>" + msg + "</div>" );
});
请试试这个
我创建了一个 DEMO 。这是我从你的问题中了解到的。如果这不是您的意思,请添加一些 html 或您尝试过的代码,以便更容易理解您的问题。
$(document).ready(function(){
$("img").mouseup(function(){
$("#containment-wrapper").css("background-color", "black");
});
$("img").mousedown(function(){
$("#containment-wrapper").css("background-color", "white");
});
});
我还没有开始我将要从事的项目,但在规划过程中我无法解决点击并按住事件问题。
我将点击 div(图像元素上方的 div,但我仍然可以点击图像),不透明度约为 0.7,它下面的图像。我将能够单击图像并在 canvas 上移动它(基本上只是将它从 canvas 的一侧移动到另一侧)。
有谁知道创建点击并按住事件的方法,当我点击图像将其移动到 canvas 时,点击 divs 不透明度变为 0(或者 div 一起隐藏),然后当我取消单击时它又回到 0.7?
谢谢!
jQuery 的 https://api.jquery.com/mousemove/ 呢? 在文档中,他们有一个示例如何将 even 绑定到目标:
$( "#target" ).mousemove(function( event ) {
var msg = "Handler for .mousemove() called at ";
msg += event.pageX + ", " + event.pageY;
$( "#log" ).append( "<div>" + msg + "</div>" );
});
请试试这个
我创建了一个 DEMO 。这是我从你的问题中了解到的。如果这不是您的意思,请添加一些 html 或您尝试过的代码,以便更容易理解您的问题。
$(document).ready(function(){
$("img").mouseup(function(){
$("#containment-wrapper").css("background-color", "black");
});
$("img").mousedown(function(){
$("#containment-wrapper").css("background-color", "white");
});
});