How can I make all <a>
link has the same target of "_self" through jQuery or javascript?
Put this in the <head>
:
<base target="_self">
No need for JavaScript - HTML has the feature built in!
$('a[href]').attr('target','_self');
Note: This will override all ANCHOR
tag's target
attribute on the page. RichieHindle's answer would be best if you just want to add them where they aren't declared.
$('a').attr('target', '_self');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With