Reputation: 1401
what i want is that changing textbox value with checkbox. when checkbox is checked, textbox must be '2020-01-01'
I did this
$('#checkPub').click(function() {
$("#demo1").val('2020-01-01');
});
It gives only me the checkbox as output why? It does not change the textbox value
Upvotes: 0
Views: 1409
Reputation: 17784
$('#checkPub').click(function() {
if($(this).is(':checked'))
$("#demo1").val('2020-01-01');
else
$("#demo1").val('');
});
Upvotes: 1