Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
Created July 5, 2011 13:07
Show Gist options
  • Save craigmdennis/1064807 to your computer and use it in GitHub Desktop.
Save craigmdennis/1064807 to your computer and use it in GitHub Desktop.
Detect if an anchor is linking to the current page
(function( $ ){
$.fn.isCurrentPage = function() {
if (window.location.href.indexOf(this.attr('href')) >= 0) {
return true;
}
else {
return false;
}
}
});
/**
*
* if ($('#myLink').isCurrentPage) {
* // do some stuff
* }
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment