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 7896681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:57:26+00:00 2026-06-03T07:57:26+00:00

I have a <div> with a bunch of text in it. This <div> also

  • 0

I have a <div> with a bunch of text in it. This <div> also has a .click() event on it using jQuery.

The problem I’m having is that the .click() is being triggered when selecting/highlighting text. Even holding the mouse down for several seconds before releasing.

Here is a JSFiddle that shows the issue: http://jsfiddle.net/ym5JX/

The behavior that I would expect is that highlighting text isn’t the same as clicking on the element.

  • 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-06-03T07:57:28+00:00Added an answer on June 3, 2026 at 7:57 am

    That’s because a click is a mousedown followed by a mouseup. My suggestion is to check getSelection inside the click handler. If it’s set, then you selected something, else you just clicked.

    $('#click').click(function() {
        var sel = getSelection().toString();
        if(!sel){
            alert("clicked");
        }
    });​
    

    DEMO: http://jsfiddle.net/ym5JX/3/

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

Sidebar

Related Questions

I'm using Jquery 1.6. I have a dropdown list that has a bunch of
I have a bunch of divs that are all hidden like this <div class=elements>
I have a bunch of text areas that are children of a div that
I have whole bunch of <div class=productlistname><a href=#>The Text!</a></div> . What I want to
I have a bunch of images that are in a hidden div. The div
If I have a container div called #container which has a bunch of .inside
I have, for example, markup like this <div id=content> <p>Here is some wonderful text,
I have a bunch of divs that I am expanding/retracting individually using .toggle and
I have this jQuery code: $('*').mouseover(function() { $('#log').text($(this)[0].tagName); }); And In my page, I
I have a bunch of tracklist content on my site that is in 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.