Question: 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!

Answer: 
Use an outerHTML jQuery plugin, like [this one](http://dbj.org/dbj/?p=91), or [this one](http://brandonaaron.net/blog/2007/06/17/jquery-snippets-outerhtml/).
you can do something like this:

```
function dump(element) {
  var a = ["Element dump:"];
  for (var k in element) {
    if (element.hasOwnProperty(k)) {
      a.push(k + ": " + element[k]);
    }
  }
  a.push("HTML: " + element.innerHTML);
  alert(a.join('\n'));
}

```

Whether you want the "hasOwnProperty" test or not, I don't know.