我有以下代碼:何時動態創建的對象插入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