Create a jQuery Outbound Links Selector

javascript, jquery

This is a way to create a jQuery selector for ALL outbound links but this selector will only work if the HTML tag has an href attribute.

The selector name is ':outbound'

				$.extend($.expr[':'], {
					outbound: function(a,i,m) {
						if(!a.href) { return false; }
							return a.hostname && a.hostname !== window.location.hostname;
					}
				});
				
				$('a:outbound').click(function(){});