Form表单自带的reset按钮,是将表单值重置为其默认值,如果需要清空表单数据这个功能就不满足要求了,需要自己实现该功能
?
?
function clearForm(objE){//objE为form表单
$(objE).find(':input').each(
function(){
switch(this.type){
case 'passsword':
case 'select-multiple':
case 'select-one':
case 'text':
case 'textarea':
$(this).val('');
break;
case 'checkbox':
case 'radio':
this.checked = false;
}
}
);
}
?
html
?
?
<input type="button" value="重置" onclick="clearForm(this.form);"/>
?
?
?