I’m trying to assign a class that I have within the jQuery UI accordion that is matched by the URL.
Example:
Inside the jQuery Accordion, I have the following links (they do not include the hostname):
Which is dynamically generated links.
I want to be able to give an active class to one of those links if that links page is the current opened page (active in the URL address bar).
Ideally I’d like to be able to detect by the ?pcat= alone, in case the colours change.
Anyone know how I can do this? Was trying this code:
<script type="text/javascript">
$(document).ready(function() {
$(function(){
var matches;
if( matches = (new String(document.location)).match(/?pcat=/) ) {
$("a[href=" + matches[0] + "]").addClass('active');
}
});
The url needs to end (
href$=) with the color:EDIT I just realized your urls don’t end with
pcat=.... Use this instead to filter the<a>the contains the matched location substring: