If all you want is the onclick attribute, then try the following: This assumes that you did not set the event using attachEvent or addEventListener.
elm.getAttribute("onclick");
If you want to make an outerHTML string (just promise not to take it apart after you make it):
function outerHTML(elm){
var ret = "<"+elm.tagName;
for(var i=0; i<elm.attributes.length; i++){
var attr = elm.attributes[i];
ret += " "+attr.name+"=\""+attr.nodeValue.replace(/"/, "\"")+"\"";
}
ret += ">";
ret += elm.innerHTML+"</"+elm.tagName+">";
return ret;
}
This function should do the trick in most cases, but it does not take namespaces into account.