0
   $(document).ready(function() {
    $(".voteMe").one('click', function (event) { 
              event.preventDefault();          
           //my stuff

$(this).prop('disabled', true);
        });
    });

the above code is allowing single mouse click.but it is not allowing next click i mean next single mouse click it is assuming double click. my final conclusion is i want allow all single clicks and dis allow double clicks(when ever consumer enter double click it will take only single click only)

user2750450
  • 51
  • 1
  • 1
  • 2

5 Answers5

1

Use following Code

 $(".voteMe").click(function (e) {
        if ($(this).hasClass('clicked')) return;
        $(this).addClass('clicked');
         setTimeout(function() { $(this).removeClass('clicked'); }, 500);

    });
Muhammad Tahir
  • 2,351
  • 29
  • 25
0

You can use setTimeout() function and prevent the execution of the handler in a specified period of time:

$(".voteMe").on('click', function (event) {
    if ($(this).hasClass('clicked')) return;

    var $this = $(this).addClass('clicked');
    setTimeout(function() { $this.removeClass('clicked'); }, 500);

    // ...
});
Ram
  • 143,282
  • 16
  • 168
  • 197
0

try this:

 $(document).ready(function() {
    $(".voteMe").one('click', function (event) { 
          event.preventDefault();          
       //my stuff

       $(this).prop('disabled', true);

       $(".voteMe").unbind("click");
    });
});
Gurminder Singh
  • 1,755
  • 16
  • 19
-1

You should then unbind the double click:

$('.voteMe').unbind('dblclick');
aleation
  • 4,796
  • 1
  • 21
  • 35
-2

Jquery bind double click and single click separately

var DELAY = 700, clicks = 0, timer = null;

$(document).ready(function() {

$("a")
.live("click", function(e){

    clicks++;  //count clicks

    if(clicks === 1) {

        timer = setTimeout(function() {

            alert('Single Click'); //perform single-click action

            clicks = 0;  //after action performed, reset counter

        }, DELAY);

    } else {

        clearTimeout(timer);  //prevent single-click action

        alert('Double Click');  //perform double-click action

        clicks = 0;  //after action performed, reset counter
    }

})
.live("dblclick", function(e){
    e.preventDefault();  //cancel system double-click event
});

});

Community
  • 1
  • 1
Sai Sherlekar
  • 1,804
  • 1
  • 17
  • 18