My question is quite simple.. I need to convert an Element object into an html string

var thumb = new Element('img',{'src':"big.jpg"});
console.log( thumb.?????() ); //some magical method here

should return (as a string)

'<img src="_big.jpg">'

I've tried the .get('html') but it returns nothing, obviously because the img tag has nothing inside.

Thanks in advance

有帮助吗?

解决方案

Just proxy it.

var html = new Element('div').adopt(yourel).get('html');

其他提示

Have you tried outerHTML? I am pretty sure all you need is:

var html = selector.outerHTML;

Returns a collection of elements from a string of html.

http://mootools.net/docs/more/Element/Elements.From

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top