简体   繁体   中英

InnerHTML returns undefined in IE8

I'm using the following line of code in order to get the content of a XML node:

$(this).find("brand")[0].innerHTML

(The reason why there is a $(this) is only because i'm in a loop to check every nodes)

The problem is this does not work with IE, it returns undefined. I also tried different properties like textContent, nodeValue but nothing works in IE.

Does anyone know a solution ? Thanks for your time

To support custom tag selection in IE8 and below you need to add a sort of reference to the tags before the element is added to the DOM.

<!--[if lte IE 8]>
<script>
    document.createElement('brand');
</script>
<![endif]-->

Unless you do this you cannot use ("brand") as a selector in jQuery in these lower browsers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM