试图动态更改多个jQuery UI对话框()按钮.
下面代码的问题是在对话框的第一个实例中只显示一个按钮().应显示两个按钮.
$(function(){ var dlg = $('#message'); dlg.dialog({ autoOpen:false,modal:true,width: 500,close: function() { if (seen==0 && ans > 0) { cnt++; seen++; dlg.html('Here is a second message'); dlg.dialog( 'option','buttons',[{ text: 'OK',click: function() { $(this).dialog('close'); } }] ); dlg.dialog('open'); } } }); $('#myDiv').hover( function() { //Hover-in if (cnt < 1 || (cnt > 2 && cnt < 4) || (cnt > 5 && cnt < 7)) { var msg = 'First display text goes here'; dlg.html(msg); dlg.dialog( 'option',[{ text: 'Download',click: function() { ans++; $(this).dialog('close'); },text: 'Not now',click: function() { $(this).dialog('close'); } }] ); dlg.dialog('open'); } cnt++; },function() { //Hover-out //need this to prevent duplicating hover-in code (double-display dlg) } ); }); //END document.ready