Neo*_*Neo 11 javascript asp.net-mvc jquery twitter-bootstrap twitter-bootstrap-3
以下代码直接显示警告框.
<head>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Dismissal Alert Messages</h2>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
Success! message sent successfully.
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
我想在按钮点击时显示警告框可以有人帮我这样做吗?
这个jsfiddle显示了如何在点击时显示引导警报框
http://jsfiddle.net/g1rnnr8r/2/
您需要实现jquery的show()
方法.您需要使用的代码是.
$(document).ready(function(){
$('button').click(function(){
$('.alert').show()
})
});
Run Code Online (Sandbox Code Playgroud)
function showAlert(){
if($("#myAlert").find("div#myAlert2").length==0){
$("#myAlert").append("<div class='alert alert-success alert-dismissable' id='myAlert2'> <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button> Success! message sent successfully.</div>");
}
$("#myAlert").css("display", "");
}
Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<button value="showAlert" onclick="showAlert();"> Show Alert</button>
<div class="container" style="display:none;" id="myAlert">
<h2>Dismissal Alert Messages</h2>
<div class="alert alert-success alert-dismissable" id="myAlert2">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
Success! message sent successfully.
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我添加了一些ID并编写了一些代码.试着去理解,如果你没有问我.好的希望这对你有所帮助,如果没有问我更多.
归档时间: |
|
查看次数: |
81731 次 |
最近记录: |