how to print entire HTML element in JavaScript?
- by celicni
I want to print the entire element including tag name, attribute name/value pairs and innerHTML. How can I do it in JavaScript (jQuery)?
for example:
var elArr = document.getElementsByTagName('link');
alert(elArr[0].printEntireElement());
//expected output might be
<link href="/css/common.css" rel="stylesheet" type="text/css">`
Note that for link element outerHTML is not defined!