这段代码在本地执行的结果是通过添加类名的按钮不会禁止默认行为,通过添加属性的按钮会禁止默认行为,在慕课网上执行的结果是都会禁止
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>按钮状态——禁用状态</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script>
window.onload = function(){
document.getElementById("btn1").onclick = function(){
alert("btn1")}
document.getElementById("btn2").onclick = function(){
alert("btn2")}
}
</script>
</head>
<body>
<button class="btn btn-primary btn-lg btn-block" id="btn1" type="button" disabled="disabled">通过disabled属性禁用按钮</button>
<button class="btn btn-primary btn-block disabled" id="btn2" type="button" >通过添加类名disabled禁用按钮</button>
<button class="btn btn-primary btn-sm btn-block" type="button">未禁用的按钮</button>
</body>
</html>