【问题标题】:How to Refresh the Bootstrap modal fields after modal close模式关闭后如何刷新引导模式字段
【发布时间】:2018-12-12 08:37:28
【问题描述】:

我有一个带有动态输入字段的 Bootstrap 模式,我需要在关闭模式后清空所有字段值。(即)我需要在模式关闭后刷新它。 我试过clear();

$('body').on('hidden.bs.modal', '.modal', function () {
   $(this).removeData('bs.modal');
});

但不适用于我。您能否为此提出一个可行的解决方案。 提前谢谢..

【问题讨论】:

  • 您必须获取每个<input> 并清除它们的值。 Here's 一个开始
  • 谢谢 Tico,它对我有用...

标签: javascript jquery html bootstrap-modal


【解决方案1】:

只需遍历模态中的每个输入并清除其值:

$('body').on('hidden.bs.modal', '.modal', function () {
    $(this).removeData('bs.modal');
    $(this).find("input").each(function(input) {
        input.val("");
    })(
});

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2017-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    相关资源
    最近更新 更多