我有以下代码:何时动态创建的对象插入DOM?
$(function() {
var html = $('<div></div>');
html.load('preview.html', function (responseText, textStatus, XMLHttpRequest) {
$('#some_id_in_loaded_html')...
}
html.dialog();
}
然而,在IE7,在回调函数jQuery选择,因为它无法找到指定的ID失败。它在Firefox中正常工作。
为什么会发生这种情况,哪些是正确的行为(根据标准)?
请注意,这个问题很容易通过使用$('#some_id_in_loaded_html',this)
这是在'$(document).ready()'的上下文中运行吗? – jrummell 2011-12-22 13:54:28
@ jrummell:是的,它全部用一个ready() – tskuzzy 2011-12-22 13:56:48