TAGS :Viewed: 3 - Published at: a few seconds ago

[ IE8- jQuery html on non-HTML elements ]

I'm working with some XML from a database and parsing it with jQuery. This works fine everywhere except for IE8-, which I need to support. I have elements like <stem>, and I can get IE to somewhat support them by adding


etc. The problem is that some of these elements may contain HTML that I need to append to another element on the page. Something like


I can use $xml.find('stem').text() just fine, but whenever I use .html or any DOM-manipulation methods (including the .append line above), IE gives the very helpful error

Unspecified error (line 4 of jquery-min.js)

Depending upon what I try to do, I can get

Unable to get value of the property 'replace': object is null or undefined (line 4)


Is there any workaround for getting HTML from non-HTML elements (and even HTML5 elements) in IE8-?

Answer 1

IE8- will allow you to get the text value of these non-HTML elements without complaining. You can then apply this as normal html with the .html method, interestingly enough: