I'm trying to keep a checkbox checked whenever a given text input is not empty. At the moment, the text input box isn't responding to the event I added to it through jquery, and I'm wondering if there's something off in my code. (still quite new to jquery)
Here is my text input and checkbox:
<input type="text" id="textInput"/>
<input type="checkbox" id="checkBox" checked="checked" />
And here is my jquery code:
$('#textInput').on('click', function(){
//if text input is not empty
if($('#textInput').val() !== ''){
//if checkbox not checked, check it
if($('checkBox').checked !== 'checked'){
$('checkBox').checked = 'checked';
}
}
})