Possible Duplicate:
jQuery, get html of a whole element
lets say I have:
<span>my span</span>
I would like have html as a string of this span
I use:
var mySpan = $('span');
what to do with the mySpan var to have as a result string "<span>my span</span>"
thanks for any help
I think this will help: http://jsfiddle.net/HxU7B/2/.
UPDATE.
mySpan[0].outerHTMLwill take a previoulsy selected node and get a nativeouterHTMLproperty. Since old Firefox versions doesn’t have that property, we can use a bit of hack to get html – simply clone node to dummydivand then get this div’s innerHTML:$('<div/>').append(mySpan.clone()).html()