Last active
December 10, 2015 23:19
-
-
Save interfacecreation/4508589 to your computer and use it in GitHub Desktop.
Just a little snippet to check for segments in the url and add a switch statement to add classes.
This file contains 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
$(document).ready (function() { | |
// Get segments and store in variables | |
var newURL = window.location.protocol + "://" + window.location.host + "/" + window.location.pathname; | |
var pathArray = window.location.pathname.split( '/' ); | |
var segment_1 = pathArray[1]; | |
// switch cases depending on the url segment and add an active class | |
switch (segment_1){ | |
case "your_segment_value": | |
$("selector").addClass("active"); // do something | |
break; | |
case "your_other_segment_value": | |
$("#step2").addClass("active") // do something else | |
break; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment