문제

How do i assign events to a single element based on click or dblclick. Ive found jsfiddles but none of them are exact. Basically, an imitation of the instagram double tap to like or tap to visit is desired. I know how to bind the events, but not the logic.

도움이 되었습니까?

해결책

I'm pretty sure you can do what you're asking by using .on() to bind "click" or "dblclick" to a specific element.

Check out this example: http://jsfiddle.net/pcostanz/nSkVU/

Essentially I'm binding some background color changes using .on() to the "click" and "dblclick" events.

$(document).ready(function() {

    $("#singleclick").on("click", function() { 
        $(this).css('background-color', 'orange');
    });

    $("#doubleclick").on("dblclick", function() { 
        $(this).css('background-color', 'orange');
    });    

});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top