I want to disable button if user didnt add anything into global variable "code". I tryied indexOf() however it is reactive only once. Lets say if i have button that adds "z" into "code" global variable, it does not execute function inside indexOf("z"); Can anybody help?
let code = "";
$(document).ready(() => {
function codeCheck() {
if (code = "") {
console.log("nothing")
} else if (code.indexOf("z")) {
console.log("do semething")
}
}
code = "z";
codecheck();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>