Click here to Skip to main content
13,736,491 members
Rate this:
 
Please Sign up or sign in to vote.
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 13-Oct-18 9:28am
Updated 5 days ago

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can Try

var previousTarget=null;
$("a").click(function() {
    if(this===previousTarget) {
        alert("You've clicked this element twice.");
    }
    previousTarget=this;
    return false;
});
  Permalink  
Comments
5 days ago
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 14 Oct 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100