I'm currently facing an issue with my transliteration function that is supposed to be executed only when the checkbox is checked. The problem is, even after unchecking the checkbox, the function still continues to run.
const checkBox = document.querySelector("#checkbox");
const input = document.querySelector("#input");
function transRussian(){
ch = ch.replace(/l/g, "л");
ch = ch.replace(/p/g, "п");
return ch;
}
checkBox.addEventListener('change',()=>{
if(checkBox.checked){
transliterate();
}
else{
console.log("transliteration is turned off")
}
});
input.addEventListener('keyup',()=>{
var ch = input.value;
transRussian(ch);
input.value = ch;
});
<input type="checkbox" id="checkbox">
<input type="text" id="input">