简体   繁体   English

如何检查单选按钮

[英]how to check that the radio button

I have to find that the radio button is checked or not if its clicked and checked then count will increase of its.我必须发现单选按钮是否被选中,如果它被点击并被选中,那么它的计数就会增加。 And if count will increase then it will increase only one time.如果计数会增加,那么它只会增加一次。 it will not increase on multiple click on same radio button in sveltekit.在 sveltekit 中多次单击同一个单选按钮不会增加它。

在此处输入图像描述

Kindly suggest the count increment method on radio button请建议单选按钮上的计数增量方法

it will increase count when click and not increment count when multiple click on same radio button单击时会增加计数,多次单击同一个单选按钮时不会增加计数

I think the knowledge you are missing is likely how to determine if the radio is checked?我认为您缺少的知识可能是如何确定收音机是否已检查? If so, the top answer to this provides a good explanation: How can I check whether a radio button is selected with JavaScript?如果是这样,对此的最佳答案提供了一个很好的解释: How can I check a radio button is selected with JavaScript?

Something like:就像是:

var counter = 0;
if(document.getElementById('id').checked) {
  counter++;
}else{
  counter--;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM