Skip to content

Instantly share code, notes, and snippets.

@Tiny-Giant
Created August 24, 2017 22:36
Show Gist options
  • Save Tiny-Giant/412db8aa86e5cb1f483168839357bc2a to your computer and use it in GitHub Desktop.
Save Tiny-Giant/412db8aa86e5cb1f483168839357bc2a to your computer and use it in GitHub Desktop.

#BAD!

$('.link').on('click', _ => $('.link').attr('href', $('.link').attr('href').replace(/#.+/,'')));

#GOOD!

const link = $('.link');
link.on('click', _ => link.attr('href', link.attr('href').replace(/#.+/, ''));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment