Check and uncheck checkbox in Jquery

<input type="checkbox" id="nat_cover_letter">
<select id="check_uncheck">
<option value="0">Select</option>
<option value="1">Check</option>
<option value="2">Uncheck</option>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$('#check_uncheck').change(function(){
if(this.value==1)
{
$('#nat_cover_letter').attr('checked',true); // Check checkbox
}
else if(this.value==2)
{
$('#nat_cover_letter').attr('checked',false); // uncheck checkbox
}
else
{
alert('none');
}
});
</script>

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *