Skip to content Skip to sidebar Skip to footer

Click And Hold Event 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. I am going to be having a click th

Solution 1:

Please try this

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");
    });
});

Solution 2:

What about jQuery's https://api.jquery.com/mousemove/ ? In the Doc they have an example how to bind the even to a target:

$( "#target" ).mousemove(function( event ) {
    var msg = "Handler for .mousemove() called at ";
    msg += event.pageX + ", " + event.pageY;
    $( "#log" ).append( "<div>" + msg + "</div>" );
});

Post a Comment for "Click And Hold Event Javascript"