2

So I'm using Bootstrap for my project. Basically I want to have the Button disabled ("disabled" class) until the Click Count reaches a distinct number. JS Part:

 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; 
     }

Optional HTML Part:

<p><a class="btn btn-primary btn-lg disabled" id="up1bt">Purchase: C100</a></p>

Any help?

Trevor
  • 15,843
  • 8
  • 50
  • 82
kyr
  • 395
  • 2
  • 3
  • 8

1 Answers1

4

You have a spelling mistake up1btn and up1bt - The button id is up1bt but your selector is #up1btn, change the button id to up1btn.

Demo: Fiddle

Arun P Johny
  • 376,738
  • 64
  • 519
  • 520