[jQuery] Get element by class based on document.location variable
I have a set of lists with child elements – these are my navigation.
Each top level list item a has a class that corresponds to a given
section.
The child elements are hidden by default. I want a correct child list
to open based on the URL you are visiting.
The code I have is as follows:
var currentSection = document.location.toString().split('/')[4];
I then want the list item with the matching class to the var
currentSection to slide open. I thought it was this:
$("." + currentSection).slideDown(500);
But it doesn’t work!