In a userscript i am getting
[object XrayWrapper [object HTMLSpanElement]] instead of html span tag.
How can i get the html tag like
<span>--</span> from this object?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
The only difference is in the toString() method, which determines what happens when you try to turn an object into a primitive. You didn't state what you want to do, but if you're trying to turn a DOM object into HTML textual representation, then the outerHTML property should provide you with what you need.
var element = document.createElement("span"); element.appendChild(document.createTextNode("text")); alert(element.outerHTML); // returns "<span>text</span>"