代码示例:(标识:jsck_document_queryselector_attribute)
<!DOCTYPE html>
<html>
<style>
a[target] {
  background-color: yellow;
}
</style>

<body>
<h1>Document 对象</h1>

<h2>querySelector() 方法</h2>

<p>CSS 选择器 a[target] 确保所有具有 target 属性的链接都获得黄色背景:</p>

<p>将红色边框添加到具有 target 属性的第一个链接:</p>

<a href="https://www.sou-xun.com">sou-xun.com</a>
<a href="http://www.disney.com" target="_blank">disney.com</a>
<a href="http://www.wikipedia.org" target="_top">wikipedia.org</a>

<script>
document.querySelector("a[target]").style.border = "10px solid red";
</script>

</body>
</html>
运行结果: