jQuery DOM append losing markup
- by Raj
This is related to an earlier question. I try to append HTML DOM returned in an AJAX response to an existing DIV. I see all the text, but it seems all markup such as bold, italic, etc is lost.
My AJAX (XML) data is like so:
<event source="foo">
<contents>
<h1>This is an event</h1>
This is the body of the event
</contents>
</event>
My jQuery code does this:
$("#eventDiv").append( jData.find("contents").contents().clone() );
Attempting to do .html() on the cloned contents throws an exception: TypeError: Cannot call method 'replace' of undefined.
I am a little surprised that it is so excruciatingly hard to do this with jQuery. Am I doing something too far off the track?