This question already has answers here:
Resetting a multi-stage form with jQuery

(30个答案)


6年前关闭。




我想清除注册按钮单击后的所有文本框。以下是我的尝试。当我单击按钮时,文本仍然保留。请指教。谢谢
<form action="#" class="signup" method="post" onsubmit="return signup();">
    <input type="text" id="signup-email" class="text-input" name="email" title="E-mail" autocomplete="off" tabindex="11" placeholder="E-mail">
    <input type="password" id="signup-password" class="text-input" name="password" title="Password" autocomplete="off" tabindex="12" placeholder="Password">
    <input type="password" id="signup-password2" class="text-input" name="password2" title="Confirm password" autocomplete="off" tabindex="13" placeholder="Confirm password">
    <table>
        <tr>
            <td></td>
            <td class="align-right">
                <button type="submit" class="signup-btn" onclick="this.form.elements['text-input'].value=''">Register</button>
            </td>
        </tr>
    </table>
</form>

最佳答案

试试这个

<button type="submit" class="signup-btn" onclick="this.form.reset();">Register</button>

08-27 21:57
查看更多