http://jsfiddle.net/jzhang172/s83yt1L6/
我无法按下按钮。它应该像bootstrap网站上的工作一样:
http://getbootstrap.com/javascript/#buttons
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" id="myButton" data-loading-text="Loading..." class="btn btn-primary" autocomplete="off">
Loading state
</button>
<script>
$(function(){
$('#myButton').on('click', function () {
var $btn = $(this).button('loading')
// business logic...
$btn.button('reset')
});
});
</script>
&#13;
答案 0 :(得分:2)
您在更改为“加载”按钮后立即重置按钮。所以你不能看到它改变了。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" id="myButton" data-loading-text="Loading..." class="btn btn-primary" autocomplete="off">
Loading state
</button>
<script>
$(function(){
$('#myButton').on('click', function () {
var $btn = $(this).button('loading');
setTimeout(function(){$btn.button('reset');}, 1000);
// business logic...
});
});
</script>
&#13;