为什么Bootstrap类在jquery中不起作用?我正确地包含了所有脚本!
$(document).ready( function() {
$('.glyphicon glyphicon-exclamation-sign').click( function() {
alert('Hi');
})
});
答案 0 :(得分:0)
glyphicon glyphicon-exclamation-sign
是2个类名,应该是:
$('.glyphicon.glyphicon-exclamation-sign').click(...);
答案 1 :(得分:0)
你应该写这样的东西..
$(document).ready( function() {
$('.glyphicon, .glyphicon-exclamation-sign').click( function() {
alert('Hi');
})
});
答案 2 :(得分:0)
$(document).ready(function() {
$('.glyphicon-exclamation-sign').click( function() {
alert('Hi');
});
});
span i{
margin-top:50px;
margin-left:50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Click On Icon
<span><i class="glyphicon glyphicon-exclamation-sign"></i></span>