How to I get the value of a radio button with javascript

前端 未结 2 829
渐次进展
渐次进展 2020-12-06 22:39

I need to obtain the value of a radio button using javascript

I have a radio group called selection



        
2条回答
  •  孤城傲影
    2020-12-06 23:16

    Use:

    function getRadioValue(name) {
        var group = document.getElementsByName(name);
    
        for (var i=0;i

    Application:

    var selectedValue = getRadioValue('selection');
    

    Demo:

    http://www.jsfiddle.net/tqQWT/

提交回复
热议问题