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!