我需要在单击span后重置表单元素,例如.
有没有一种方法可以通过jQuery重置from而不选择每个元素并删除属性值.
一些没有属性值的元素,如textarea或radio
有些像按钮我不想从中删除它的值.
我想使用jQuery在其他事件上使用重置
代码例如http://jsfiddle.net/pgNrF/
<input type="button" value="Input Button">
<input type="checkbox">
<input type="hidden">
<textarea></textarea>
<span>Reset</span>
Run Code Online (Sandbox Code Playgroud)
ade*_*neo 10
如果您以实际形式包装这些表单元素,则已经内置了此内容:
<form id="myform">
<input type="button" value="Input Button">
<input type="checkbox">
<input type="file">
<input type="hidden">
<input type="image">
<input type="password">
<input type="radio">
<input type="submit">
<input type="text">
<select>
<option>Option1</option>
<option>Option2</option>
<option>Option3</option>
</select>
<textarea></textarea>
<button type="button">Button</button>
<button type="reset">Reset</span>
</form>
Run Code Online (Sandbox Code Playgroud)
如果你只需要使用jQuery:
$('span').click(function() {
$('#myform').get(0).reset();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15064 次 |
| 最近记录: |