Simple jQuery snippet not working in IE
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?
精彩评论