Q:

Add Class to menu li if href match with the Variable

I have a multilevel menu and I need to highlight the TOP level menu by adding the class active to the list.
Example on fiddle 
I store a value of link that needs to be active in javascript variable var activeHREF= '/news/';
I need jquery that can search through the list li and match with the href of in the list if it matches with the anchor element then it should add a class='active' to this particular list.
I this this is more efficient way to handle my scenario where I can have up to 3 or 4 multilevel menu's and i need to highlight the Top level Parent menu 
A pointer can be good way to start.

A:

I think you are looking for something like this:
$("li:has(a[href='" +activeHREF+ "']):first()").addClass("active")

A:

jsFiddle Example with multiple levels of unordered lists. 
$("a[href='" +activeHREF+ "']").parent().addClass("active")

Using filter can do the same thing
$('a').filter(function() {
    return $(this).attr('href') == activeHREF;
}).parent().addClass('active');

