Reputation: 35
I have the following:
It triggers automatic click
on button when I select a checkbox
. However, What should I do to unclick
or deselect the button. I have tried unbind()
, but does not seem to work.Any help would be great.
if(this.checked) {
$("#input").trigger('click');
}
else {
$("#input").unbind('click');
}
Upvotes: 0
Views: 732
Reputation: 867
Are you looking for this fiddler
var check = document.getElementById('check');
var btnsend = document.getElementById('send');
check.onchange = function() {
btnsend.click();
btnsend.disabled = !!this.checked;
};
sendbtn.onclick=function(){
alert("hello");
}
Upvotes: 0
Reputation: 1696
You need to update your code as below:-
HTML
<input type="checkbox" id="checkme"/><input type="submit" name="sendNewSms" class="inputButton" id="sendNewSms" value=" Send " />
JS
var checker = document.getElementById('checkme');
var sendbtn = document.getElementById('sendNewSms');
checker.onchange = function() {
sendbtn.disabled = !!this.checked;
};
Upvotes: 1