开发者

How do I change the contents of a div inside a modal dialog using JQuery

开发者 https://www.devze.com 2022-12-12 03:32 出处:网络
I have the following jQuery dialog and I want to change the contents of a div inside the dialog just before I open it. However I can\'t seem to fathom it out, can any one help?

I have the following jQuery dialog and I want to change the contents of a div inside the dialog just before I open it. However I can't seem to fathom it out, can any one help?

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

$("#dialog").dial开发者_StackOverflow中文版og({
    bgiframe: true, height: 140, modal: true, autoOpen: false
});

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

Thanks.


Use

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

not $("#data").html = "My new text";. There is no property html on a jQuery object. Instead there is a function html(val) to set the html content, of every element matched with the selector (in your case #data.

0

精彩评论

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