我使用ct-js-productForm库创建了一个模型表单,但现在我想使用click事件打开该模型。 现在,当我通过默认刷新页面时,模型已打开。我想在点击事件中打开该模型。
This string 1234 is repeated. Repeated 1 times.
答案 0 :(得分:0)
将模态类添加到#Registration div
$(function() {
var options = {
"backdrop" : "static",
"show": true
}
$("#register").on("click", function() {
console.log('hi');
$('#Registration').modal(options);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<a href="#" id="register"><i class="fa fa-plus-square"></i> Register</a>
<div class="ct-popupForm ct-js-productForm modal fade" id="Registration">
<div class="container">
<form role="form" class="center-block" method="POST">
<div class="form-group">
<div class="ct-form-content">
<div class="row">
<div class="col-md-6">
<label>First Name</label>
<input type="text" required class="form-control input-lg" value="Kristine" placeholder="">
<label>Last Name</label>
<input type="text" required class="form-control input-lg" value="Black" placeholder="">
<label>Number of Properties</label>
<input type="text" required class="form-control input-lg" value="15" placeholder="">
<label>Include contact form?</label>
</div>
</div>
<button type="submit" class="btn btn-success center-block">Save changes</button>
</div>
<div class="ct-form-close"><i class="fa fa-times"></i></div>
</div>
</form>
</div>
</div>
答案 1 :(得分:0)
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<a href="#" id="register"><i class="fa fa-plus-square"></i> Register</a>
<div class="modal fade" id ="Registration">
<div class="container">
<form role="form" class="center-block" method="POST">
<div class="form-group">
<div class="ct-form-content">
<div class="row">
<div class="col-md-6">
<label>First Name</label>
<input type="text" required class="form-control input-lg" value="Kristine" placeholder="">
<label>Last Name</label>
<input type="text" required class="form-control input-lg" value="Black" placeholder="">
<label>Number of Properties</label>
<input type="text" required class="form-control input-lg" value="15" placeholder="">
<label>Include contact form?</label>
</div>
</div>
<button type="submit" class="btn btn-success center-block">Save changes</button>
</div>
<div class="ct-form-close"><i class="fa fa-times"></i></div>
</div>
</form>
</div>
</div>
<script>
$('document').ready(function() {
var options = {
"backdrop" : "static",
"show":true
}
$("#register").on("click", function(){
$('#Registration').modal(options);
});
});
</script>
</body>
</html>
&#13;
答案 2 :(得分:0)
你忘记了;在这结束时。
var options = {
"backdrop" : "static",
"show":true
};
在#Registration div块中添加第二个类“modal fade”或将display:none设置为#Registration div