+14 votes
483 views
in Programming by (11.7k points)

I have a website but most link do not have _blank attribute and I cannot edit all of these links. is it possible to achieve this problem with jQuery?

For example:

<a href="http://wikitechsolutions.com">Home</a>

<a href="http://wikiwhy.net" target="_blank">Other site</a>

<a href="index.html">Home</a>

<a href="/">Home</a>

1 Answer

+5 votes
by (26.3k points)

$('a[href^="http://"], a[href^="https://"]').not('a[href*=gusdecool]').attr('target','_blank');

 

 

Ask a Question
Welcome to WikiTechSolutions where you can ask questions and receive answers from other members of the community.

You can ask a question without registration.

Categories

...