我正在尝试清除模式弹出窗口中的先前文本,但我无法做到这一点我已经搜索了互联网,但找不到任何适合我的问题的解决方案,我正在分享我的代码,请指导我
JQUERY:
$('table').on('click', function(e){
e.preventDefault();
var clone = $(this).clone();
$( "#popup" ).dialog({
open: function( event, ui ) {
$(this).html(clone);
},
buttons: {
"Okay": function () {
$(this).dialog("close");
},
},
});
$("#sumresult").clone(true).appendTo("div.ui-dialog-buttonpane").show();
});
HTML:
<table>
<tr>
<th>Part</th>
<th>ID</th>
</tr>
<tr>
<td>New part</td>
<td>231134</td>
</tr>
<tr>
<td>New part</td>
<td>231134</td>
</tr>
</table>
<div id="popup" title="Table Preview"></div>
<div id="sumresult">12390.21</div>
fiddle :http://jsfiddle.net/hg9NJ/3/
当我一次又一次打开 modal
时,它会多次显示相同的值。
最佳答案
清除弹窗的html
$('table').on('click', function(e){
$(".ui-widget-content").html(""); // clear html
e.preventDefault();
var clone = $(this).clone();
$( "#popup" ).dialog({
open: function( event, ui ) {
$(this).html(clone);
},
buttons: {
"Okay": function () {
$(this).dialog("close");
},
},
});
$("#sumresult").clone(true).appendTo("div.ui-dialog-buttonpane").show();
});
关于javascript - 无法清除 jquery 模式弹出窗口上的先前文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24168590/