为什么我的帖子没有重置?

时间:2017-10-06 08:40:10

标签: javascript jquery html twitter-bootstrap-3

你能帮我解决一下我的帖子吗?关闭模态窗口后,我会尝试实现重置表单,并发送有关发送的消息,但它不起作用!为什么?我使用的是Bootstrap 3。

<form id='send-form' action="#" method="post" target="iframe1">
    <div class="input-field">
        <input type="text" name="name" class="form-control" placeholder="name">
    </div>
    <div class="input-field">
        <input type="email" name="email" class="form-control" placeholder="e-mail...">
    </div>
    <div class="input-field">
        <input type="text" name="subject" class="form-control" placeholder="Тема...">
    </div>
    <div class="input-field">
        <textarea name="message" class="form-control" placeholder="message"></textarea>
    </div>
    <div class="input-field">
        <input type="checkbox" checked autocomplete="on" name="law">check</input>
    </div>
    <button type="submit" id="submit" class="btn btn-blue btn-effect" data-toggle="modal" 
    data-target="#modal-send">send</button>

</form>

<div class="modal" id="modal-send">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button id='reset-but' class="close" type="button" data-dismiss="modal">
                <i class="fa fa-close fa-2x"></i></button>
                <script>
                    $(index.html).ready(function(){
                    $('#reset-but').click(function () {
                    $('#send-form')[0].reset();
                    });});
                </script>
                <h4 class="modal-title">Сообщение отправлено<br><br></h4>
            </div>
       </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:1)

只需删除$(index.html).ready(function(){}即可使用

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id='send-form' action="#" method="post" target="iframe1">
    <div class="input-field">
        <input type="text" name="name" class="form-control" placeholder="name">
    </div>
    <div class="input-field">
        <input type="email" name="email" class="form-control" placeholder="e-mail...">
    </div>
    <div class="input-field">
        <input type="text" name="subject" class="form-control" placeholder="Тема...">
    </div>
    <div class="input-field">
        <textarea name="message" class="form-control" placeholder="message"></textarea>
    </div>
    <div class="input-field">
        <input type="checkbox" checked autocomplete="on" name="law">check</input>
    </div>
    <button type="submit" id="submit" class="btn btn-blue btn-effect" data-toggle="modal" data-target="#modal-send">send</button>

</form>

<button id='reset-but' type="button" data-dismiss="modal">
<i class="fa fa-close fa-2x"></i></button>
<script>
$('#reset-but').click(function () {
$('#send-form')[0].reset();
});
</script>
<h4 class="modal-title">Сообщение отправлено<br><br></h4>
&#13;
&#13;
&#13;