Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:05:53+00:00 2026-05-30T20:05:53+00:00

How can I define in jQuery was it a regular click on the same

  • 0

How can I define in jQuery was it a regular click on the same element or double-click?

For example we have element like this:

<div id="here">Click me once or twice</div>

And we need to perform different actions after regular click and double-click.

I tried something like this:

$("#here").dblclick(function(){
    alert('Double click');
});
$("#here").click(function(){
    alert('Click');
});

But, of course, it doesn’t work, everytime works only ‘click’.

Then, some people showed me this:

var clickCounter = new Array();
$('#here').click(function () {
clickCounter.push('true');
setTimeout('clickCounter.pop()', 50);
if (clickCounter.length > 2) {
    //double click
    clickCounter = new Array(); //drop array
} else {
    //click
    clickCounter = new Array(); //drop array    !bug ovethere
}
});

Here we tried to set the interval between clicks, and then keep track of two consecutive events, but this have one problem.. it doesn’t work too.
So, someone knows how to do this? or can someone share a link to the material, where I can read about it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:05:54+00:00Added an answer on May 30, 2026 at 8:05 pm

    From QuirksMode:

    Dblclick

    The dblclick event is rarely used. Even when you use it, you should be
    sure never to register both an onclick and an ondblclick event handler
    on the same HTML element. Finding out what the user has actually done
    is nearly impossible if you register both.

    After all, when the user double–clicks on an element one click event
    takes place before the dblclick. Besides, in Netscape the second click
    event is also separately handled before the dblclick. Finally, alerts
    are dangerous here, too.

    So keep your clicks and dblclicks well separated to avoid
    complications.

    (emphasis mine)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can define icon for a jquery ui button in code like this; $(
That is, can I define a selector called :shiny and do this? $$('div.shiny') //undesired
I have a list of DIVs, like this : <div id=list> <div class=classA classB
You can define 2 variables of the same type in a for loop: int
I can define default value in domain by this way : class ProcessingPriority {
How can I define an alternate close button for jQuery dialog? I want an
I have a jQuery search script that uses tabs for the user to define
I have a jQuery search script that uses tabs for the user to define
I have a jQuery search script that uses tabs for the user to define
I can't seem to get this to work in jquery. I am using this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.