jQuery Plugin Lab
What's wrong with this plugin?
by anandhinava
HTML
<a href="http://www.google.com" rel="external">Google</a>
<a href="http://www.yahoo.com" rel="external">Yahoo</a>
<a href="http://www.bing.com" rel="external">Bing</a>
<a href="#" class="local">Local</a>
JavaScript
(function ($, document, window, undefined) {
$.fn.externalize = function () {
return this.each(function () {
var $this = $(this);
if ($this.attr('rel') == 'external') {
$this.attr('target', '_blank').append('\u2B00');
}
});
};
})(jQuery, document, window);
$("a").externalize().css('color', 'green');