jquery check checkbox

This example checks the checkbox below using the jquery .prop() function .

Opt in

Code

<input type="checkbox" name="myCheckbox" value="Bike" id="myCheckbox">Opt in <button type="button" onclick="gofunc()" >Go!</button>
<script>
function gofunc()
{
$('#myCheckbox').prop('checked', true);
}
</script>