Jquery – How to change the contents of a div inside a modal dialog using JQuery

jquery, jquery-ui

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").dialog({    bgiframe: true, height: 140, modal: true, autoOpen: false});$("#data").html = "My new text"; /*THIS DOES NOT WORK*/$("#dialog").dialog('open');


Best Solution


$("#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.