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

如何使用.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()方法起作用了。

这可能是其中一个原因吗?


收到一只叮咚
浏览 374回答 3
3回答

慕田峪4524236

您可以尝试使用触发器()参考链接$('#form_id').trigger("reset");

元芳怎么了

根据这个职位这里,jQuery没有reset()方法,但本机JavaScript可以。因此,可以使用以下两种方法将jQuery元素转换为JavaScript对象:$("#formId")[0].reset()//&nbsp;or$("#formId").get(0).reset()
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JQuery