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

Home Forums JavaScript Removing :active pseudo class when mouseup occurs outside of clicked element

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #33931

    Picture this scenario: a user clicks an anchor that has an :active pseudo class applied to it. If the user releases the mouse when cursor is still in the boundaries of that anchor, the :active class is removed. But if the user drags the mouse and leave the boundaries of that anchor, the :active class just stays there until next mouse click.

    Is there a known solution/workaround for this issue?

    I’ve tried sorting this out with jQuery’s mousedown() and mouseup() events, but it’s the same logic – the mouseup() won’t register as a click unless it occurs on the same element where the mousedown() occurred.

    Help would be much appreciated.

    EDIT: Found a solution thanks to Google’s search button. Just changed the markup from anchor tag to a button tag.


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