$("#note_content").dialog({ title: "Note",modal: true,width:'auto',height:'auto',resizable:false,open: function(){ var note_text = $('#note_content').attr('note_text'); } }
解决方法
您应该在对话框中有一个内容占位符,例如:
<div id="noteContent" title="Basic dialog"> <p id="contentholder"> This is the default dialog which is useful for displaying information. The dialog window can be moved,resized and closed with the 'x' icon.</p> </div> $("#note_content").dialog({ title: "Note",open: function(){ var note_text = $('#note_content').attr('note_text'); $("#contentholder").val(note_text) } }
您已将note_text分配给此行中的变量:
var note_text = $('#note_content').attr('note_text');
但是,您没有将note_text变量分配给占位符.