Can you detect “dragging” in jQuery?

On mousedown, start set the state, if the mousemove event is fired record it, finally on mouseup, check if the mouse moved. If it moved, we’ve been dragging. If we’ve not moved, it’s a click. Here’s a demo: http://jsfiddle.net/W7tvD/1399/

Dynamically replace image source with jQuery

I’m trying to replace the default Yelp star rating image for businesses with one of my own. To do so I need to find the corresponding image source for each of the possible 5 images that could have loaded. And then, based on that I need to load in the proper image I’ve created. So, … Read more

Getting URL hash location, and using it in jQuery

Editor’s note: the approach below has serious security implications and, depending upon the version of jQuery you are using, may expose your users to XSS attacks. For more detail, see the discussion of the possible attack in the comments on this answer or this explanation on Security Stack Exchange. You can use the location.hash property … Read more

jQuery delay not working

.delay() is used for items that are part of a queue, like animations. A simple addClass is not queued. You could use setTimeout. As an alternative, you could add the non-queued item to the queue using .queue(), though I think a setTimeout would be better.

Show div #id on click with jQuery

The problem you’re having is that the event-handlers are being bound before the elements are present in the DOM, if you wrap the jQuery inside of a $(document).ready() then it should work perfectly well: An alternative is to place the <script></script> at the foot of the page, so it’s encountered after the DOM has been loaded and ready. To … Read more