Hi just like the title I want to do this by JQuery please.
Question
Share
Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
jQuery 1.6+
Use the new .prop() method:
[code]$(‘.myCheckbox’).prop(‘checked’, true);
$(‘.myCheckbox’).prop(‘checked’, false);[/code]
jQuery 1.5.x and below
The .prop() method is not available, so you need to use .attr().
[code]$(‘.myCheckbox’).attr(‘checked’, true);
$(‘.myCheckbox’).attr(‘checked’, false);[/code]
Note that this is the approach used by jQuery’s unit tests prior to version 1.6 and is preferable to using
[code]$(‘.myCheckbox’).removeAttr(‘checked’);[/code]
since the latter will, if the box was initially checked, change the behaviour of a call to .reset() on any form that contains it – a subtle but probably unwelcome behaviour change.
For more context, some incomplete discussion of the changes to the handling of the checked attribute/property in the transition from 1.5.x to 1.6 can be found in the version 1.6 release notes and the Attributes vs. Properties section of the .prop() documentation.