Your HTML is a bit of a mess, so I might be missing something but the following should work:
Code:
document.observe('dom:loaded', function() { //need to do it once everything's loaded
//then grab 'all a-tags inside countries wrapper' and call 'observe' on them with arguments:
$$('#countries_wrapper a').invoke('observe', 'click', function(e) {
e.stop();
fadeOut(this.href); //in an event observer, 'this' is the element being clicked
});
});
where fadeout is the same as yours, but with 'href' as it's argument.
Alternatively, you could use event-delegation and attach just one observer to the container:
Code:
document.observe('dom:loaded', function() {
$('countries_wrapper').observe('click', function(e) {
if(e.element().match('a')) { //if it's an 'a' tag
e.stop();
fadeOut(e.element().href);
}
});
});