Created
June 22, 2017 14:44
-
-
Save Blumed/3fdf930e0f00d81d9c12ea2eb2a6f8b6 to your computer and use it in GitHub Desktop.
Handy way to prevent default by adding logic to a click with # in href
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a').on('click', function(e) { | |
if($(this).attr('href') === '#') { | |
e.preventDefault(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment