$("a[target='_blank']") Selects all <a> elements with a target attribute value equal to "_blank" - Javascript jQuery

Javascript examples for jQuery:Selector

Description

$("a[target='_blank']") Selects all <a> elements with a target attribute value equal to "_blank"

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("a[target='_blank']").hide();
    });/* w  w  w  . j av a  2 s .c  o m*/
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<p><a href="http://java2s.com/" target="_blank">HTML Tutorial</a></p>
<p><a href="http://java2s.com/">CSS Tutorial</a></p>

<button>Click me</button>

</body>
</html>

Related Tutorials