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: 
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.
If you want to print an entire tag from a jQuery element you could do something like this:

```
var el = $('<div id="my_div">test div 123</div>');

alert(el[0].outerHTML);

```