如何在javascript中为放置在引导模式中的表单设置密码和用户名

如何在javascript中为放置在引导模式中的表单设置密码和用户名,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我已经使用bootstrap3设置了一个登录模式,如链接中所述 在JavaScript代码中,如何将用户名和密码设置为登录表单的特定值。 我还在学习html和css。我对javascript了解不多。您可以试试: HTML代码: <div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div c

我已经使用bootstrap3设置了一个登录模式,如链接中所述

在JavaScript代码中,如何将用户名和密码设置为登录表单的特定值。 我还在学习html和css。我对javascript了解不多。

您可以试试:

HTML代码:

<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Login</h4>
        </div>

        <div class="modal-body">
            <!-- The form is placed inside the body of modal -->
            <form id="loginForm" method="post" class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-3 control-label">Username</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="username" id="username" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">Password</label>
                    <div class="col-sm-5">
                        <input type="password" class="form-control" name="password" id="password" />
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-5 col-sm-offset-3">
                        <button type="submit" class="btn btn-default">Login</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
记住包括twitter引导。其

尽管我不确定直接设置密码是否是最好的主意。

请查看:谢谢:)尽管我使用php进行了验证,但我只是想知道该方法!
$('#loginModal').on('shown.bs.modal', function() {
      $('#username').val('example@gmail.com');
      $('#password').val('123456');
});
$('input[name="username"]').val('user');
$('input[name="password"]').val('password')