Frage

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.

War es hilfreich?

Lösung

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

});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top