编辑下面的代码:【加编码】
<html> <head> <style> a[target] { background-color: yellow; } </style> </head> <body> <p> CSS 选择器 a[target] 确保所有有 target 属性的链接背景颜色为黄色:</p> <a href="/">ziqiangxuetang.com</a> <a href="http://www.disney.com" target="_blank">disney.com</a> <a href="http://www.wikipedia.org" target="_top">wikipedia.org</a> <p>点击按钮为带有 target 属性的链接添加红色背景。</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { document.querySelector("a[target]").style.border = "10px solid red"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂