javascript - 无法清除 jquery 模式弹出窗口上的先前文本

标签 javascript jquery html

我正在尝试清除模式弹出窗口中的先前文本,但我无法做到这一点我已经搜索了互联网,但找不到任何适合我的问题的解决方案,我正在分享我的代码,请指导我

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

FIDDLE DEMO

$('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/

相关文章:

javascript - JSON.parse 在控制台中有效,但在运行脚本时无效

javascript - 动态创建的元素上的事件绑定(bind)?

html - "flash"颜色,使用纯 css 过渡

html - 将 Azure Application Insights 嵌入第三方应用程序

javascript - 使用 AngularJS 服务构建 html 部分

javascript - 多个处理程序附加到一个事件 : How to detach only one?

javascript - 为什么按回车键弹出窗口不关闭

javascript - 如何在 div 出现后一秒钟删除它?

javascript - 网页优化

jquery - 如何将 backstrech 插件应用于 div,而不是 body 标签?