How to get the outer html of an element using jQuery ?
Sometimes, there is a need to get the entire HTML element by its id and not merely its contents, for doing so, we shall use the HTML DOM outerHTML Property to get the outer HTML of HTML element.
You can use a variable and initialize it to the above to get the value of the outer HTML element. Below is an example that illustrates how to fetch the outer HTML element of an HTML element and store it in a variable newVar.
<div id="demo"> <p>This is the text inside</p> </div>
Example 2: This example illustrates that the outerHTML DOM displays only the HTML element whose id is given and not its parent
<p id="demo">This is the text inside</p>