官方的解釋是,reset() 方法可把表單中的元素重置爲它們的默認值。
</pre><p></p><p><span style="font-family:Verdana,Arial,宋體; background-color:rgb(249,249,249)">那麼問題來了,當你的表單元素如下</span></p><p></p><pre code_snippet_id="1964263" snippet_file_name="blog_20161103_2_2773768" name="code" class="html"><form action="#" id="form1">
<input type="text" id="username">
<input type="text" id="password">
<input type="text" id="test" value="testValue">
<input type="reset" value="reset">
</form>
當你修改這個表單的時候,即使把testValue修改了,你使用reset的時候它會變回來,而上面的username和password的內容都會爲空。
它恢復了id=test 的input的默認值。而不是將它清空。