我正在使用jquery对话框供用户输入注释,而不是我在jquery对话框中添加和取消按钮。我有一个逻辑,就像他们点击添加我需要在数据库中插入文本和刷新整个HTML页面中的iframe。一切都很完美。但是当iframe刷新时,它会保留dom事件中的旧对话框。所以,当我第二次点击时,它会出现在预期的屏幕上。但我不确定为什么第一次点击它会保留旧的jquery对话框。
我正在使用此代码:;
$("#dialog-confirm").dialog({
resizable: false,
height: 200,
modal: true,
autoOpen: false,
buttons: [
{
id: "add_btn",
text: "Add",
disabled: true,
click: function () {
// logic of adding text in db goes here.
$(this).dialog("close");
}
},
{
id: "cancel_btn",
text: "Cancel",
click: function () {
$(this).dialog("close");
}
}
]
});
提前致谢。
答案 0 :(得分:0)
function resetForm($form) {
$form.find('input:text, input:password, input:file, select, textarea').val('');
$form.find('input:radio, input:checkbox')
.removeAttr('checked').removeAttr('selected');
}
并致电resetForm($('#myform')); // by id
或强>
jQuery.fn.reset = function () {
$(this).each (function() { this.reset(); });
}
致电$("#FormID").reset();
或强>
$('#FormID').each (function(){
this.reset();
});
如果您使用上面代码的表单是正确的,但不会被使用 like this
$("#clear").click(function(){
$("input[type='text']").val("");
});
答案 1 :(得分:0)