本文實例講述了JavaScript實現重置表單(reset)的方法。分享給大家供大家參考。具體如下:
下面的代碼可以對表單內的輸入數據進行重置
<!DOCTYPE html>
<html>
<head>
<script>
function formReset()
{
document.getElementById("frm1").reset();
}
</script>
</head>
<body>
<p>Enter some text in the fields below,
then press the "Reset form" button to reset the form.</p>
<form id="frm1">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
<input type="button" onclick="formReset()" value="Reset form">
</form>
</body>
</html>
希望本文所述對大家的javascript程序設計有所幫助。