[英]How to reset a form using: input type=reset
嗨,這是我的第一個問題,如果我理解錯了,請原諒我。
我正在嘗試使用HTML5中的input type = reset標記來重置表單,但是出現問題。 我將放入代碼的一部分,我要問的問題是:表單是否位於單獨的div中是否重要? 我將使用Javascript,因此如果您能告訴我一個簡單的JS方法會很棒,但jQuery不會,那么您可以提供的任何幫助都會很棒!
這一切都在一個領域。
<div id="formset">
<label for="textfield" class="form">First Name:</label>
<input type="text" name="textfield" id="textfield" class="input">
<p></p>
<label for="textfield2">Last Name:</label>
<input type="text" name="textfield2" id="textfield2" class="input">
<p></p>
<label for="email"></label>
<input type="email" name="email" id="email" class="input">
<p></p>
<label for="date"></label>
<input type="date" name="date" id="date" class="input"></div> <input type="reset" value="Reset">
I think you need to use form tag. Here is my code:
<form action="" method="">
<div id="formset">
<label for="textfield" class="form">First Name:</label>
<input type="text" name="textfield" id="textfield" class="input">
<p></p>
<label for="textfield2">Last Name:</label>
<input type="text" name="textfield2" id="textfield2" class="input">
<p></p>
<label for="email"></label>
<input type="email" name="email" id="email" class="input">
<p></p>
<label for="date"></label>
<input type="date" name="date" id="date" class="input">
</div>
<input type="reset" value="Reset">
</form>
沒有表單標簽,表單不能聲明為表單。 您可以在使用表單標簽時使用所有表單事件,例如提交,重置等。 像這樣
<form action="" method="">
your inputs.....
</form>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.