Skip to content

Instantly share code, notes, and snippets.

@dbridgman
Last active October 2, 2015 16:15
Show Gist options
  • Save dbridgman/6a4ba8c34a13120a386d to your computer and use it in GitHub Desktop.
Save dbridgman/6a4ba8c34a13120a386d to your computer and use it in GitHub Desktop.
The if statement targets the URL
Add an ID to the target you want to add the class to,
Then enter it into the following line, alongside the name of the class you want:
"jQuery('#ID-NAME').addClass('CLASS-NAME');"
<!-- CODE TO USE IS BELOW -->
jQuery(function() {
var loc = window.location.href; // returns the full URL
if(/YOUR-URL/.test(loc)) {
jQuery('#ID-NAME').addClass('CLASS-NAME');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment