我正在尝试以模态形式添加带蒙版输入插件的蒙版,但我很难做到。我不知道为什么它不起作用,有人可以帮我告诉我代码有什么问题吗?
<script src="js/jquery.maskedinput.js" type="text/javascript"></script>
<!-- Modal -->
<div class="modal fade" id="cadastromodal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal">
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
Cadastrar novo contato
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" role="form" method="POST" action="cadastrocontato.php">
<div class="form-group">
<label class="col-sm-2 control-label"
for="inputEmail3" id="nome">Nome</label>
<div class="col-sm-10">
<input type="nome" name="nome" class="form-control"
id="nome" placeholder="Nome"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"
for="inputEmail3">Email</label>
<div class="col-sm-10">
<input type="email" name="email" class="form-control"
id="email" placeholder="Email"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"
for="inputEmail3" id="telefone">Telefone</label>
<div class="col-sm-5">
<input type="telefone" name="telefone" maxlength="10" class="form-control"
id="telefone" placeholder="Telefone"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"
for="inputEmail3">Celular</label>
<div class="col-sm-5">
<input type="celular" name="celular" maxlength="10" class="form-control"
id="celular" placeholder="Celular"/>
</div>
</div>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">
Cancelar
</button>
<button type="submit" class="btn btn-primary" data-toggle="modal">
Cadastrar
</button>
</div>
</div>
脚本:
<script>
jQuery(function($){
$("#Telefone").mask("(99) 9999-9999");
});
</script>