How to check a radio button with jQuery

0 votes

I try to check a radio button with jQuery. Here's my code:

<form>
    <div id='type'>
        <input type='radio' id='radio_1' name='type' value='1' />
        <input type='radio' id='radio_2' name='type' value='2' />
        <input type='radio' id='radio_3' name='type' value='3' /> 
    </div>
</form>

And the JavaScript:

jQuery("#radio_1").attr('checked', true);

Doesn't work:

jQuery("input[value='1']").attr('checked', true);

Doesn't work:

jQuery('input:radio[name="type"]').filter('[value="1"]').attr('checked', true);

Doesn't work:

Do you have another idea? What am I missing?

Jun 9 in JQuery by Anchal
• 320 points
9 views

1 answer to this question.

0 votes

“jquery datepicker format” Code Answer's

  1. $('#timePicker'). datetimepicker({
  2. // dateFormat: 'dd-mm-yy',
  3. format:'DD/MM/YYYY HH:mm:ss',
  4. minDate: getFormattedDate(new Date())
  5. });
  6. function getFormattedDate(date) {
  7. var day = date. getDate();
answered Jun 10 by gaurav
• 12,980 points

Related Questions In JQuery

0 votes
1 answer

How to check a radio button with jQuery?

For versions of jQuery equal or above ...READ MORE

answered Jun 3 in JQuery by Edureka
• 13,640 points
14 views
0 votes
1 answer

How to check a radio button with jQuery?

We can check the status of a ...READ MORE

answered Jun 10 in JQuery by rajatha
• 4,060 points
5 views
0 votes
1 answer

How to check if a jQuery plugin is loaded?

Hello @kartik, for the plugins that doesn't use ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,720 points
698 views
0 votes
1 answer

How to check if button is disabled in jQuery Mobile?

Hello, you can try $("#deliveryNext").is(":disabled") The following code works for ...READ MORE

answered May 29, 2020 in JQuery by Niroj
• 82,720 points
2,074 views
0 votes
1 answer

How to scroll to element from bottom to top with a nice animation using Jquery?

Hello @kartik, Assuming you have a button with ...READ MORE

answered Sep 10, 2020 in JQuery by Niroj
• 82,720 points
2,491 views
0 votes
1 answer

How to find a parent with a known class in jQuery?

Hello @kartik, Assuming that this is .d, you can write $(this).closest('.a'); The closest method returns the ...READ MORE

answered Oct 5, 2020 in JQuery by Niroj
• 82,720 points
1,849 views
0 votes
1 answer

How to set radio option checked onload with jQuery?

Hii, Say you had radio buttons like these, ...READ MORE

answered Nov 24, 2020 in JQuery by Niroj
• 82,720 points
1,721 views
0 votes
1 answer

How to disable all <input > inside a form with jQuery?

To disable all form elements inside 'target', ...READ MORE

answered Jun 3 in JQuery by Edureka
• 13,640 points
8 views
0 votes
1 answer
0 votes
1 answer

How can I refresh a page with jQuery?

Use the JavaScript location. reload() Method You can simply ...READ MORE

answered Jun 10 in JQuery by gaurav
• 12,980 points
24 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP