$("p:first") Selects the first <p> element - Javascript jQuery

Javascript examples for jQuery:Selector

Description

$("p:first") Selects the first <p> element

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(){
        $("p:first").hide();
    });//  w  w w. j a v  a 2s  .  co  m
});
</script>
</head>
<body>

<h2>This is a heading</h2>

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

<button>Click me</button>

</body>
</html>

Related Tutorials