function event() {
$('main').css("display", "none");
$('section').css("display", "block");
}
function startButton(){
if($('input').val() === true){
$('button').on('click', event)
} else if($('input').val() === false){
$('button').off('click', event)
}
}
startButton()
when I do if statement with if($('input').val() === "") the click event works whether the user typed text in input or not when I check the Boolean on console it returns true or false depending on the input value is filled or not
I would like to add click event on the button when the user types in the input and remove the click event when there is no text written in the input
can someone help me with my code?
Aucun commentaire:
Enregistrer un commentaire