Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
Hello there. I have one button and if I click this button 2 times I want to alert message. how do I do jquery?

What I have tried:

I tried onclick and dblclick but i cant.
Posted
Updated 14-Oct-18 2:59am

1 solution

You can Try

var previousTarget=null;
$("a").click(function() {
    if(this===previousTarget) {
        alert("You've clicked this element twice.");
    }
    previousTarget=this;
    return false;
});
 
Share this answer
 
Comments
[no name] 14-Oct-18 13:06pm    
but the button is doing response.redirect. so 'return false' does not work when you do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900