如何使用jQuery重置特定的表单字段
问题描述:
我想知道如何使用jQuery重置特定表单字段。
I want to know how to reset a particular form field using jQuery.
我正在使用以下函数:
function resetForm(id) {
$('#'+id).each(function(){
this.reset();
});
}
但重置所有字段。有没有办法使用jQuery或JavaScript重置特定字段?我想只重置一个特定字段。
but it is resetting all the fields. Is there any way to reset specific fields using jQuery or JavaScript? I want to reset only a particular field.
答
function resetForm(id) {
$('#' + id).val(function() {
return this.defaultValue;
});
}
不使用id的示例: