ok, assuming I understand you correctly, you can do something like this...
var link = $(".foo");//or select your link another way
var linkClass = link.attr("class");
if($("body").hasClass(linkClass)){
//link has matching class
link.addClass("newClass");
}
As you can see I have used the hasClass() JQuery function to check if the body tab has the matching class.
If your link will potentially have more than one class name you can do it like this...
var link = $(".foo");//or select your link another way
var linkClass = link.attr("class");
var classList = linkClass.split(/\s+/);
var matchFound = false;
for(var i = 0; i < classList.length; i++){
if($("body").hasClass(classList[i])){
//link has matching class
matchFound = true;
}
}
if(matchFound){
link.addClass("newClass");
}
Also, if you want to process all your links at the same time you could wrap it all in a JQuery each() and change the first line like so...
$("a").each(function(index){
var link = $(this);
//the rest of the above code here
});