点击并按住事件Javascript [英] Click and hold event Javascript

查看:120
本文介绍了点击并按住事件Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有开始要进行的项目,但是在计划过程中,我很难确定点击并按住事件的问题.

I havent gotten started on the project I'm going to be working on, but in planning I'm having trouble figuring out a click and hold event issue.

我将要单击一个div(位于图像元素上方的div,但我仍然可以单击图像),其不透明度大约为0.7,且其下面的图像.我将能够单击图像并在画布上四处移动(基本上只是将其从画布的一侧移到另一侧).

I am going to be having a click through div (a div that is over the image element, yet I can still click on the image) with an opacity somewhere around 0.7 with an image below it. I will be able to click on the image and move it around on a canvas (basically just move it from one side of the canvas to the other).

有人知道创建点击并按住事件的方法吗?当我单击图像以将其移动到画布上时,div的单击不透明度变为0(或者div全部隐藏起来),然后我取消点击它回到0.7吗?

Does anyone know of a way to create a click and hold event where when I am clicking on the image to move it on the canvas, the click through divs opacity becomes 0 (or the div become hidden all together), then when i un-click it goes back to 0.7?

谢谢!

推荐答案

请尝试此操作

我创建了演示.这是我从您的问题中了解到的.如果这不是您的意思,请添加一些您尝试过的html或代码,以使其易于理解您的问题.

I have created a DEMO . This is what I understood from your question. If this is not what you meant please add some html or code you have tried so that its easy to understand your problem.

$(document).ready(function(){
    $("img").mouseup(function(){
        $("#containment-wrapper").css("background-color", "black");
    });
    $("img").mousedown(function(){
        $("#containment-wrapper").css("background-color", "white");
    });
});

这篇关于点击并按住事件Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆