How does jquery obtain the radio value?

Source: Internet
Author: User

How does jquery obtain the radio value?

Use jquery to obtain the radio value. The most important thing is to know how to use the jquery selector. in a form, we usually need to obtain the selected radio.

So you need to add checked for filtering, such as the following radio items:

1.Jquery gets the radio Value

2.Jquery obtains the checkbox Value

3.Jquery obtains the select Value

To obtain a radio value, you can use the following methods:

1. 1. $ ('input [name = "testradio"]: checked'). val ();

2. 1. $ ('input: radio: checked'). val ();

3. 1. $ ('input [@ name = "testradio"] [checked] ');

4. 1. $ ('input [name = "testradio"] '). filter (': checked ');

It's almost complete. If we want to traverse all radio whose name is testradio, the Code is as follows: 1. $ ('input [name = "testradio"] '). each (function ()

{Alert (this. value );});

If you want to obtain a specific radio value, such as the Second radio value, write

1. $ ('input [name = "testradio"]: eq (1) '). val ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.