Implementation Code of jQuery operation inputtype = radio

Source: Internet
Author: User
JQuery operates the implementation code of inputtyperadio. For more information, see As follows:

BeijingTianjinNanjingYangzhouSuzhou

1. Obtain the value of the selected radio:

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

Use the element selector, use the attribute Filter name = 'city', and use: checked to select the selected element.

2. Set the selected status for the specified radio value:

$("input[name='city'][value='YangZhou']").attr("checked",true);

Set the radio status for name = "city" and value = "YangZhou.

3. deselect the radio status of name = "city:

$('input[name="city"]:checked').attr("checked",false);

4. Obtain the number of radio for name = "city:

$("input[name='city']").length;

5. obtain radio with name = "city" and an even number of indexes:

$("input[name='city']:even");

The index starts from 0.

6. Obtain the radio with name = "city" and an odd index:

$("input[name='city']:odd");

The index starts from 0.

7. Iterative radio:

$ ("Input [name = 'city']"). each (function (I, obj) {// I, subscript of iteration, starting from 0 // obj, current object (HTMLInputElement), can use obj. get the property value in the value format // $ (this); the current jQuery object can use $ (this ). val () Get attribute value });

Iteration name = "city" radio.

8. Disable radio:

$("input[name='city']").attr("disabled",true);

Disable radio for name = "city.

9. enable radio:

$("input[name='city']").attr("disabled",false);

Enable radio for name = "city.

For more information about jQuery input type = radio implementation code, see PHP!

Related Article

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.