dc

IE7/8 .text() vs .html()

So .text() doesn’t work for retrieving the content. The solution use .html(). The problem with this is that in IE 7/8 you end up with extra white space in the content. The solution $.trim(), and now you have your content the same as modern browsers using .text().

This stumped me long enough while using a value in jQuery’s inArray function and it wasn’t finding the entry, even though I knew that the value existed in the array. Not the most friendly for modern browsers, but maintains backwards compatibility with older version of IE.

Leave a reply