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.
That’s because a
clickis amousedownfollowed by amouseup. My suggestion is to checkgetSelectioninside theclickhandler. If it’s set, then you selected something, else you just clicked.DEMO: http://jsfiddle.net/ym5JX/3/