Losing MouseUp event if releasing not over the same element

前端 未结 3 709
天涯浪人
天涯浪人 2021-01-15 04:34

I have got a problem with a slider. When i grab the handler, i change the .src of the image, just to change its color. However, i want it to change back to the original colo

相关标签:
3条回答
  • 2021-01-15 04:41

    How about onmouseout event?

    0 讨论(0)
  • Here is the code. I load the handler function when the document is ready.

    function handler()
    {
    
        var handler = $('handler');
    
        Event.observe(window, "mouseup", function(){
            alert('salta');   //to see when mouseup fires
            if(handler.src=='http://localhost/moodle/blocks/videoavatar/eggface/trunk/gripper_o.png'){    //orange
                handler.src='http://localhost/moodle/blocks/videoavatar/eggface/trunk/gripper.png';}    //grey
        });
    
    
        Event.observe(handler,'mousedown',function(){handler.src='http://localhost/moodle/blocks/videoavatar/eggface/trunk/gripper_o.png';});    //orange
    
    }
    
    0 讨论(0)
  • 2021-01-15 04:52

    You should be attaching the mouseup handler to the document object.

    0 讨论(0)
提交回复
热议问题