2009-11-19 70 views
1

我有以下jQuery對話框,我想在打開對話框之前更改對話框中div的內容。然而,我似乎無法理解,任何人都可以幫忙嗎?如何使用JQuery更改模式對話框中div的內容

<div id="dialog" title="Basic dialog"> 
<div id="data"></div> 
</div> 

$("#dialog").dialog({ 
    bgiframe: true, height: 140, modal: true, autoOpen: false 
}); 

$("#data").html = "My new text"; /*THIS DOES NOT WORK*/ 
$("#dialog").dialog('open'); 

謝謝。

回答

5

使用

$("#data").html("My new text"); 

$("#data").html = "My new text";。 jQuery對象上沒有屬性html。相反,有一個功能html(val)設置html內容,與選擇器匹配的每個元素(在你的情況下,#data

+0

+1爲答覆,男孩我看不到樹霧通過!我是這樣一個瘸子! 非常感謝 – Rippo

相關問題