pleasedontbelong
pleasedontbelong

Reputation: 20102

Mootools Element to HTML

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

Upvotes: 3

Views: 1379

Answers (3)

Lee Goddard
Lee Goddard

Reputation: 11173

Returns a collection of elements from a string of html.

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

Upvotes: 0

Dimitar Christoff
Dimitar Christoff

Reputation: 26165

Just proxy it.

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

Upvotes: 3

Josh Mein
Josh Mein

Reputation: 28645

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

var html = selector.outerHTML;

Upvotes: 2

Related Questions