Is there a way to change a particular attribute of all HTML elements of a certain tag with javascript or php (or anything else)? For example, I’d like to use javascript to change all “<a>” elements on the page to have the “target=’_blank'” attribute. Any suggestions?
Share
The following jQuery code will add a target=”_blank” attribute to all anchor (a) elements on a page:
You will need to include a copy of jQuery in your HTML’s head element, before the script above. So your head element will look something like: