Return the text content of all p elements - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:text

Description

Return the text content of all p elements

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(){
        console.log($("p").text());
    });//from  www.j  av  a2 s. c o m
});
</script>
</head>
<body>

<button>test</button>

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

</body>
</html>

Related Tutorials