Home > Web Front-end > JS Tutorial > Summary of how to operate Radio using jquery_jquery

Summary of how to operate Radio using jquery_jquery

WBOY
Release: 2016-05-16 16:33:16
Original
1195 people have browsed it

Radio is often used in development to achieve user selection effects. I have accumulated some methods of using JQUERY to operate Radio in the project. I will share them here for friends in need to learn from.

1. Change the radio selection and trigger some effects

Copy code The code is as follows:

$("input:radio[name='dialCheckResult']").change(function (){ //Dial
alert(“123”);
});

2. Make all radios in the page available.

$("input:radio").attr("disabled",false);

3. Make all radios in the page unavailable.

$("input:radio").attr("disabled","disabled");

4. Make a radio selected.

$("input:radio[name='dialCheckResult']").eq(0).attr("checked",true);

5. Make the "unselected" radio in the page unavailable.

$("input:radio:not([checked])").attr("disabled","disabled");

6. Traverse the radios in the selected state. Except for one radio, the radio settings in the other "selected" states are in the "unselected" state.

Copy code The code is as follows:

$('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])").attr("disabled","disabled");

8. Get the radio value of a selected specific NAME.

var dialCheckResult=$("input:radio[name='dialCheckResult']:checked").val() ;

9. Put all radios in the "selected" state into the "unselected" state.

$('input:radio:checked').attr('checked',false);

10. Put all radios on the page into the "selected" or "unselected" state.

$("input:radio").attr("checked",true);

$("input:radio").attr("checked",false);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template