所以我正在为我的项目使用Bootstrap。基本上我想要禁用Button(“禁用”类),直到Click Count达到一个不同的数字。 JS部分:
var timesClicked = 0; //main click variable
var CPC = 5;
var up1cost = 100; //cost for upgrade 1
function btnClick(){
timesClicked = timesClicked + CPC; //increases clicks by 1
$("#timesClicked").html(timesClicked) //parses over via jquery
if(timesClicked <= up1cost){
$("#up1btn").addClass("disabled")
} else {
$("#up1btn").removeClass("disabled")
}
return true;
}
可选HTML部分:
<p><a class="btn btn-primary btn-lg disabled" id="up1bt">Purchase: C100</a></p>
任何帮助?