开发者

Simple jQuery snippet not working in IE

开发者 https://www.devze.com 2023-02-19 08:08 出处:网络
Instead of using jQuery all the time, I instead built a String and then tried to parse it to jQuery. However, on IE I got a weird error message for the following snippet. It works fine on Chrome.

Instead of using jQuery all the time, I instead built a String and then tried to parse it to jQuery. However, on IE I got a weird error message for the following snippet. It works fine on Chrome.

$('&开发者_如何学Pythonlt;tr><td>a</td></tr>');

Using just this results in the following error message on IE:

Object doesn't support this property or method 'getElementsByTagName'

What's going on here? In Chrome, like I said, it works blissfully and just as I would expect, but IE refuses to understand it.

Any clues would be greatly appreciated.

Edit: Even this fails, is it just me having this problem?

$('<td>a</td>');


You could start with a <table> and .append('<tr>...</tr>') to it, or if it's still empty, use .html('<tr>...</tr>') to fill it.


IE8 and under are very particular about TD and TR elements. I do not believe you can create a document fragment (which is what you are doing) containing these types of elements without a parent table element.


Perhaps IE is looking for a top level <table> ... </table> to surround the tr and td?

0

精彩评论

暂无评论...
验证码 换一张
取 消