to make sure you get http://foo.com, http://bar.foo.com/about, and not http://bazfoo.com, try:
$("a[href*='/foo.com'], a[href*='.foo.com']").addClass('your_class');
Here's a stronger solution with regular expressions, this is probably slower, mind you, but checks the domain is on the start:
$("a").filter(
function(){
return $(this).attr('href')
.match(/^https?:\/\/([^/]*\.)?foo\.com(\/.*|$)/i);
})
.addClass('your_class');
Here are some test cases: http://jsbin.com/oruhu
(you can edit it here: http://jsbin.com/oruhu/edit ).