jQuery html() get html content

Description

jQuery html() get html 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  w  w w .  j a  v a2 s.c o  m*/
<script>
$(document).ready(function(){
  $("button").click(function(){
    document.getElementById("demo").innerHTML = $("p").html();
  });
});
</script>
</head>
<body>

<p id="demo"></p>
<button>Return the content of the p element</button>

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

</body>
</html>



PreviousNext

Related