document.getElementById("images").children[0] to a string
The toString() method will output [object HTMLImageEle开发者_StackOverflow中文版ment]. I want a string representation of the the image element '<img src="..." />'. outerHTML returns undefined in firefox.
How can I accomplish this?
outerHTML is not cross-browser.
The easiest way is to clone the element and add it to a parent element, then get the innerHTML of that:
var outer = document.createElement('outer'),
child = document.getElementById(“images”).children[0].cloneNode(true);
outer.appendChild(child);
var imgHtml = outer.innerHTML;
加载中,请稍侯......
精彩评论