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/).
If you can't do outerHtml, clone it, create a new div, place the clone in the div, and grab the innerHTML of the container.