Skip to content

Instantly share code, notes, and snippets.

@vjt
Created May 25, 2011 12:48
Show Gist options
  • Save vjt/990900 to your computer and use it in GitHub Desktop.
Save vjt/990900 to your computer and use it in GitHub Desktop.
Highlight HTML elements whose ID is equal to the anchor part of the URL
// Highlight HTML elements whose ID is equal to the anchor part of the URL
// Tags: dom_id, jQuery, Rails, Javascript
//
$(function ()
if (/^#(\w+_)+\d+$/.test (document.location.hash)) {
var element = $(RegExp.lastMatch);
element.css ({backgroundColor: '#ffffd7'}).highlight ();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment