Javascript examples for DOM:Document querySelector
Document querySelector() Method - Get the first <a> element in the document that has a "target" attribute:
<!DOCTYPE html> <html> <head> <style> a[target] {// ww w. ja v a 2 s . com background-color: yellow; } </style> </head> <body> <a href="http://www.java2s.com">java2s.com</a> <a href="http://www.disney.com" target="_blank">disney.com</a> <a href="http://www.wikipedia.org" target="_top">wikipedia.org</a> <button onclick="myFunction()">Test</button> <script> function myFunction() { document.querySelector("a[target]").style.border = "10px solid red"; } </script> </body> </html>