I am stuck trying to apply a class to a surrounding list element based on the id of the link element contained inside :
var itemId = 1; // set itemid from current url
var tabId = 'tab'+itemId; // set tabid based on itemid e.g a#tab1, a#tab2 ...
// add class selected to li containing tabid
$("#tabs ul li").each(function(){
$(this).has("a#" + tabId + "").addClass("selected");
});
Help appreciated!
You can use
Working Demo http://jsfiddle.net/f6nPx/
A faster way to do (almost) the same thing