Jquery 引导-在模式窗口上设置文本框值

Jquery 引导-在模式窗口上设置文本框值,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,我已尝试将事件“show”绑定到我的模式中,但在显示时没有发生任何事情。 以下是本应起作用的代码。 警报未显示 <script type="text/javascript" charset="utf-8"> $('#myModal').bind('show',function() { alert('howdy'); $(".modal-body #nome").val('b

我已尝试将事件“show”绑定到我的模式中,但在显示时没有发生任何事情。
以下是本应起作用的代码。
警报未显示

<script type="text/javascript" charset="utf-8">
            $('#myModal').bind('show',function()
            {
                alert('howdy');
                $(".modal-body #nome").val('bosta');
            });
        </script>

$('#myModal').bind('show',function()
{
警惕(“你好”);
$(“.modal body#nome”).val('bosta');
});

模式窗口代码:

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">Minha Conta</h3>
            </div>



            <div class="modal-body">
                <form class="form-horizontal" id="mConta">
                    <div class="control-group">
                        <label class="control-label">Nome</label>
                        <div class="controls">
                            <input id="nome" name="nome" type="text" placeholder="" class="input-xlarge" required="">

                        </div>
                    </div>

                </div>
            </form>



            <div class="modal-footer">
                <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
                <button type="submit" class="btn btn-primary">Salvar</button>
            </div>
        </div>

×
明哈康塔
诺姆
取消者
萨尔瓦多

如果脚本位于标题部分,则需要将代码封装在
DOM就绪事件中

$(function() {
  $('#myModal').bind('show',function(){
      alert('howdy');
      $("#nome").val('bosta');
  });
});

这个答案对我来说不管用,但这个答案管用

$("#mymodal #mymodal-label").html("My New Title");

在发布html代码之前或之后,您将js放在何处?因此,在脚本执行时,您的模式不存在,因此不会发生绑定。你应该按照苏珊特的回答去做。我只是因为博斯塔才投票的哈哈