It’s my mistake again. It’s morning and I realized my little code as shown below did not work properly on IE 7 and IE8.
var i = $('#someStuff').html().indexOf("<a>");
It turns out that in IE 7 and IE 8, the HTML tags returned by .html() are all in uppercase. Thus the result is not as expected. Luckily, this is not the case anymore in the latest version, IE 10. So, in order to solve the problem, the code has to be modified to be as follows by converting the result to have lowercase.
var i = $('#someStuff').html().toLowerCase().indexOf("<a>");
Actually this is an known issue in older version of IE. It’s just that I forgot about it.
Meanwhile, I also found some interesting articles about this.
In the past, there were people having a debate on whether the weird behavior of innerHTML or html() in IE 7/8 is a feature or bug. For example, there is a discussion on this in 2008: Bug of Feature – Live .innerHTML in IE.
Currently, XHTML1.0 is still an implemented standard in most of the Internet browsers. In XHTML 1.0: The Extensible HyperText Markup Language (Second Edition), it points out that XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.
Anyway, I would like to thank Microsoft engineers for making IE 10 to do the right things. Here is a promo video of IE 10.