jQuery html() method allows you to get content from element or set new content to matched element. This also includes HTML tags. If no any element is matched, it returns undefined.
Syntax:
$(selector).html();
Here is the example below how you can get content and set new content to the element:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="container">
<div id="paragraph">
<p>Hello Earth!</p>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
console.log($('#paragraph').html()); // <p>Hello Earth!</p>
$('#paragraph').html('<p>Hello World!</p>');
console.log($('#paragraph').html()); // <p>Hello World!</p>
</script>
</body>
</html>
I hope it will help you.