Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make links in a specific div open in new tab

I want to open links in my post on a new page or a new tab rather. But only the link in the specific division, not all the links on my page. I don't wanna put _blank in all my tags it's too time consuming. How can I do that?

Thanks in advance.

like image 378
Aayush Avatar asked Nov 12 '10 04:11

Aayush


1 Answers

With jQuery, you could set the target to _blank for all your links. E.g.

$(function(){
  $("#myDiv a").attr("target","_blank");
});

Example on jsFiddle.

like image 136
Gert Grenander Avatar answered Sep 19 '22 16:09

Gert Grenander