Using jquery to manipulate the Radio method
- 2020-03-30 04:11:52
- OfStack
In the development, Radio is often used to realize the user's selection effect. In the project, I have accumulated some methods of using JQUERY to operate Radio. I will share them here for those friends who need to learn from them.
1. Change the selection of radio to trigger some effects
$("input:radio[name='dialCheckResult']").change(function (){ //Called < br / >
alert( " 123 " );
});
2. Make all the radio available on the page.
$(" input: radio "). Attr (" disabled ", false);
3. Make all the radio's on the page unavailable.
$(" input: radio "). Attr (" disabled ", "disabled");
4. Put a radio in the selected state.
$(" input: radio [name = 'dialCheckResult'] "). The eq (0). The attr (" checked ", true);
5. Make the "unchecked" radio on the page unavailable.
$(" input: radio: not (/ checked) "). The attr (" disabled ", "disabled");
6. Iterate over the selected state of radio. Except for one radio, the setting of other "selected" state of radio is "not selected" state.
$('input:radio:checked').each(function(i,val){
if(val.name != "dialCheckResult" ){
$("input:radio[name='"+val.name+"']:checked").attr('checked',false);
}
});
7. Make all "unselected" radios unavailable.
$(" input: radio: not (/ checked) "). The attr (" disabled ", "disabled");
Get the value of the radio for a selected particular NAME.
Var dialCheckResult = $(" input: radio [name = 'dialCheckResult'] : checked "). The val ();
9. Put all selected radio in the unselected state.
$(' input: radio: checked). Attr (" checked ", false);
10. Put all the radio on the page in the "selected" or "not selected" state.
$(" input: radio "). Attr (" checked ", true);
$(" input: radio "). Attr (" checked ", false);