实例 jQuery 选择 targe 属性值等于 "_blank" 的所有 a 元素

x
 
<!DOCTYPE html>
<html>
<head>
<script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("a[target='_blank']").hide();
  });
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p><a href="https://cankaoshouce.com/html/" target="_blank">HTML Tutorial</a></p>
<p><a href="https://cankaoshouce.com/css/">CSS Tutorial</a></p>
<button>Click me</button>
</body>
</html>
                    

输出结果