Question

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

Était-ce utile?

La solution

Just proxy it.

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top