无法清除 jquery 模态弹出窗口上的先前文本 [英] cannot clear previous text on jquery modal popup
本文介绍了无法清除 jquery 模态弹出窗口上的先前文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试清除模式弹出窗口上的先前文本,但我无法做到这一点我已经搜索了互联网但找不到任何合适的解决方案,我正在分享我的代码,请指导我
I'm trying to clear the previous text on the modal popup but I cannot do that I have searched internet but couldn't found any appropriate solution to my problem, I'm sharing my code please guide me
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>
小提琴:http://jsfiddle.net/hg9NJ/3/
当我一次又一次地打开 modal
时,它会在我打开时多次显示相同的值.
when I open modal
again and again it will show the same value multiple times as I open.
推荐答案
只需清除弹窗的 html
Just clear the html of the popup
$('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();
});
这篇关于无法清除 jquery 模态弹出窗口上的先前文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文