The method of jquery to determine whether the radio is selected: 1. Use the selected value to determine the selected; 2. Use the checked attribute to determine the selected; 3. Jquery to obtain the value of the radio radio button; 4. Set the radio button to be selected.
The operating environment of this tutorial: windows7 system, jquery 3.2.1 version, this method is applicable to all brand computers.
Recommendation: jquery video tutorial How to
judge whether a radio is selected by jquery:
1. Use the selected value to determine the selected value and
directly upload the code, don’t forget to quote the JQuery package. The
code is as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Male
Female Very
satisfied
Satisfied
Dissatisfied
Very bad
Radio cannot be judged by "checked" equality, only use true to judge The
code is as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2. Use the checked attribute to judge the selected
radio cannot be judged by the equality of "checked", only use true to judge the
code is as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Three, jquery obtains the value of the radio button.
Another: judge whether the radio is selected and obtain the selected value. The
code is as follows:
1
2
3
4
5
6
7
function checkradio(){ var item = $(":radio:checked"); var len=item.length; if(len>0){ alert("yes--The selected value is: "+$(":radio:checked").val()); } } Fourth, set the radio button to be The selected code is as follows: 1 $("input[type=radio]").attr("checked",'2');//Set the item with value=2 as the currently selected item. Related free learning recommendations: javascript (video)
How does jquery determine whether the radio is selected
Guess you like
Origin blog.csdn.net/an17822307871/article/details/112691206
Recommended
Ranking