Force links in a specific div open in new tab - Javascript jQuery

Javascript examples for jQuery:Link

Description

Force links in a specific div open in new tab

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.3.min.js"></script> 
  <script type="text/javascript">
    $(function(){//from  ww w.  j  a v a2s  .c  o  m
$("a").attr("target","_blank");
    });

      </script> 
 </head> 
 <body> 
  <a href="http://java2s.com/">java2s</a> 
  <br> 
  <a href="http://java2s.com/">java2s</a> 
  <br> 
  <a href="http://java2s.com/">java2s</a>  
 </body>
</html>

Related Tutorials