jQuery text() get text content

Description

jQuery text() get text content

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*from www  .  j  a  v a2  s  .  c  om*/
<script>
$(document).ready(function(){
  $("button").click(function(){
    document.getElementById("demo").innerHTML = $("p").text();
  });
});
</script>
</head>
<body>

<p id="demo"></p>
<button>Return the text content of all p elements</button>

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

</body>
</html>



PreviousNext

Related