My goal is to make the title of every external link equal to its href attribute.
My question is, how can I make the title
variable available to the attr
function?
$('a').filter(function() {
var title= $(this).attr('href');
return this.hostname && this.hostname !== location.hostname;
})
.removeAttr('target')
.attr('rel', 'external')
.attr('title', title);
$('a[rel="external"]').click( function() {
window.open( $(this).attr('href') );
return false;
});
I think I somehow have it backwards, and the answer is in attr(key, fn)