jQuery .dblclick() double click

jQuery .dblclick() bind an event handler to the "double click" JavaScript event, or trigger that event on an element;

js:


$(function(){

    $('.target').dblclick(function() { // bind an event handler to the double-click event

        $(this).toggleClass('btn-primary');

        $('.log').append(' double-click-event');

    });

    

    $('.trigger').click(function() { // trigger the double-click event manually

        $('.target').dblclick();

        $('.log').append(' double-click-trigger');

    });

});​

html:


<div class="well">

    <p>

        <span class="target btn btn-primary">double-click me</span>

        <span class="trigger btn btn-inverse">click me to trigger double-click event manually</span>

    </p>

    <div class="log alert alert-block">log</div>

</div>

3 thoughts on “jQuery .dblclick() double click”

Leave a Comment