Monday 13 June 2016

How to add class external to anchor that has href to other sites

Add class external to anchor that has href to other sites and target _blank to open them to new tab



jQuery

jQuery('a').filter(function() {
   return this.hostname && this.hostname !== location.hostname;
}).addClass("external");
jQuery('.external').attr('target','_blank');
banner
Previous Post
Next Post

0 comments: