Friday 24 June 2016

How to add external link in target and class

<head>
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type='text/javascript'>
$( document ).ready(function() {

  $('a').filter(function() {
  return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');

  $('a').filter(function() {
  return this.hostname && this.hostname !== location.hostname;
}).addClass("external");

});
    </script>
</head>

No comments:

Post a Comment