I need to parse an entire Html tag into a string which I selected using the "this" keyword in the Html tag.
Example:
<button id="3" onClick="print(this)">B3</button>
<script type="text/javascript">
function print(element)
{
console.log(element);
var x = element.toString()
console.log(x)
}
</script>
when we check the first console, the result will be:
<button id="3" onClick="print(this)">B3</button>,
In the second console, the result will be:-
[object HTMLButtonElement],
Is there any way I can parse the tag into string like :
"<button id="3" onClick="print(this)">B3</button>"