bootstrap中modal框数据不清空,怎么解决

$('#myModal').on('hidden.bs.modal', function () {
    $('#fm').data('bootstrapValidator').destroy();
    $('#fm').data('bootstrapValidator', null);
    clearForm($('#fm'));
    formValidator();    //重新加载验证
});

    //清空文本框内容
function clearForm(form) {
    // input清空
    $(':input', form).each(function () {
        var type = this.type;
        var tag = this.tagName.toLowerCase(); // normalize case
        if (type == 'text' || type == 'password' || tag == 'textarea')
            this.value = "";
            // 多选checkboxes清空
            // select 下拉框清空
        else if (tag == 'select')
            this.selectedIndex = -1;
    });
};

我是又手动清空了一次

猜你喜欢

转载自blog.csdn.net/qq_39459412/article/details/83038769