Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to select all elements with target="_blank" ?

user-image
Question added by doaa elsayed , معلم حاسب ألى , مدرسة الأنفوشى الرسمية (لغات)
Date Posted: 2017/04/13
Yew Gin Kee
by Yew Gin Kee , IT Chief , Recron (M) Sdn. Bhd.

document.querySelectorAll('.hello a') .forEach(function(element) { element.setAttribute('target', '_blank'); }) <html><body> <div class="hello"><a href="https://www.bayt.com">Bayt</a> <a href="https://www.cisco.com">Cisco</a></div></body></html>

<a href="site.com" target="_blank">go to site</a>

Md Jalal Uddin
by Md Jalal Uddin , Junior software engineer , SCOPE IT

$("a[target='_blank']").attr('target','sometarget');

shamsul hasan
by shamsul hasan , Web Developer & Administration , Al Futtaim Carillion

<a href='careers.html' target='_blank'>Careers</a>

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.