为了账号安全,请及时绑定邮箱和手机立即绑定

如何使用.reet()方法使用jQuery重置表单

如何使用.reet()方法使用jQuery重置表单

收到一只叮咚 2019-07-26 15:14:14
如何使用.reet()方法使用jQuery重置表单我有工作代码,当我点击重置按钮时,可以重置我的表单。然而,在我的代码变得越来越长之后,我意识到它不再工作了。 <div id="labels">         <table class="config">             <thead>                 <tr>                     <th colspan="4"; style= "padding-bottom: 20px; color:#6666FF; text-align:left; font-size: 1.5em">Control Buttons Configuration</th>                 </tr>                 <tr>                     <th>Index</th>                     <th>Switch</th>                     <th>Response Number</th>                     <th>Description</th>                 </tr>             </thead>             <tbody>                 <form id="configform" name= "input" action="#" method="get">                 <tr><td style="text-align: center">1</td>                     <td><img src= "static/switch.png" height="100px" width="108px"></td>                     <td id="small"><input style="background: white; color: black;" type="text" value="" id="number_one"></td>                     <td><input style="background: white; color: black;" type="text"  id="label_one"></td>                 </tr>                 <tr>                     <td style="text-align: center">2</td>                     <td><img src= "static/switch.png" height="100px" width="108px"></td>                     <td id="small"><input style="background: white; color: black;" type="text" id = "number_two" value=""></td>                     <td><input style="background: white; color: black;" type="text"  id = "label_two"></td>                 </tr>                 <tr>                     <td style="text-align: center">3</td>                     <td><img src= "static/switch.png" height="100px" width="108px"></td>                     <td id="small"><input style="background: white; color: black;" type="text" id="number_three" value=""></td>                     <td><input style="background: white; color: black;" type="text" id="label_three"></td>                 </tr>而.reset()方法起作用了。这可能是其中一个原因吗?
查看完整描述

3 回答

?
慕田峪4524236

TA贡献1875条经验 获得超5个赞

您可以尝试使用触发器()参考链接

$('#form_id').trigger("reset");


查看完整回答
反对 回复 2019-07-27
?
元芳怎么了

TA贡献1798条经验 获得超7个赞

根据这个职位这里,jQuery没有reset()方法,但本机JavaScript可以。因此,可以使用以下两种方法将jQuery元素转换为JavaScript对象:

$("#formId")[0].reset()// or$("#formId").get(0).reset()


查看完整回答
反对 回复 2019-07-27
  • 3 回答
  • 0 关注
  • 373 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信