jquery - Root element in html method -
in jquery .html()
method somehow not return root element, example:
var test = $('<root><val>hello world</val></root>'); var str = test.html(); // '<val>hello world</val>'
how can string root tag included?
you want outerhtml
property. firefox doesn't support it, you'll need include fix:
var str = test[0].outerhtml || $('<div>').append(test).html();
working example: http://jsfiddle.net/ub244/
Comments
Post a Comment