how to get innertext in jquery code example

Example 1: jquery change text

$(yourElement).html("New text");
//sets yourElement innerHTML to "New text"
var text = $(yourElement).html();
//html() returns the text inside yourElement if you pass no parameters

Example 2: jquery get element innertext

const copiedText = $('#element').text();

Example 3: jquery find by innertext

$( "div:contains('innerText')" );

Example 4: get div text jquery

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>text demo</title>
  <style>
  p {
    color: blue;
    margin: 8px;
  }
  b {
    color: red;
  }
  </style>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<p><b>Test</b> Paragraph.</p>
<p></p>
 
<script>
var str = $( "p" ).first().text();
$( "p" ).last().html( str );
</script>
 
</body>
</html>