Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Return false works for click — not mousedown?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #152356
    Rugg
    Participant

    I recently discovered an issue with preventing default behavior or returning false using jQuery .mousedown() . Below are 2 test cases I’ve made; the first using click and the second mousedown. The first test executes properly…returning false and removing the #hash from the url. The second using mousedown fails, and the hash remains in the url.

    Any ideas why click works, but mousedown doesn’t?

    Edit: I’m thinking this happens because a click event is firing immediately after the mousedown. So essentially both mousedown AND click will fire when using mousedown. To fix this, you must also return false for click. Am I on the right track?

    Test Click: http://jsfiddle.net/VLZzY/show

    Test Mousedown: http://jsfiddle.net/6CdRZ/show

    Updated : http://jsfiddle.net/XHDTF/show

    #152365
    Paulie_D
    Moderator

    What is the default behaviour of mousedown?

    A click is essentially a two stage process isn’t it,a mousedown followed by a mouseup….isn’t it?

    I confess I’m a noob at this stuff.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.