Milli
Milli

Reputation: 11

How to uncheck a checkbox by default?

I have tried to find the answer to this question, but everything that I have tried did not work. (including putting 'false' 'not' etc in the code)

Right now this checkbox is checked by default, but I want to make the default to the unchecked box. (So it's not unchecking a checked box with jquery, I would like it to be unchecked in the first place.)

The code goes as follows:

<?php if (FEC_SHIPPING_ADDRESS == 'true') { ?>
if (!jQuery('#shippingAddress-checkbox').is(':checked')) {
<?php if (ACCOUNT_GENDER == 'true') echo '  check_radio("gender_shipping", "' . addslashes(ENTRY_GENDER_ERROR) . '");' . "\n"; ?>

Upvotes: 1

Views: 10457

Answers (2)

VIDesignz
VIDesignz

Reputation: 4783

Here you go man,

$('#CheckBoxIdName').removeAttr('checked');

Upvotes: 1

Mustansir Golawala
Mustansir Golawala

Reputation: 69

Removing the "checked" attribute completely from the checkbox input element will cause the checkbox to become unchecked. Adding the valueless "checked" attribute to the input element will cause it to become checked.

http://www.w3schools.com/tags/att_input_checked.asp

Upvotes: 0

Related Questions