Home > database >  Javascript if variable value equal to variable value
Javascript if variable value equal to variable value

Time:07-05

I have code like this in my website

var created = 10;
var limitacc = 25;
var element = document.querySelector(".progress-bar");

if (created.value === limitacc.value){
element.classList.add("bg-danger");
} else {
element.classList.add("bg-warning");
}

I want to change the bootstrap progress bar bg if created is same value in limitacc but the code is not working its stay in bg-warning even the created to 25

CodePudding user response:

Just remove .value

var created = 10;
var limitacc = 25;
var element = document.querySelector(".progress-bar");

if (created=== limitacc){
element.classList.add("bg-danger");
} else {
element.classList.add("bg-warning");
}
  • Related