Js获取radio的选中值

普通的radio的选中值获取方式如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
        alert("123");
        $("input[name='radio']").click(function(){
            if($(this).val() == "男"){
                $("#message").show();
            }else{
                $("#message").hide();
            }
        });
    });
</script>
</head>
<body>
    <label id="radio">性别:</label>
    <input name="radio" type="radio" checked="checked" value="男"/>男
    <input name="radio" type="radio" value="女"/>女 <br/>
    <div id="message">welcome</div>
</body>
</html>

form表单中radiobuttons的基本设置如下:

<form:radiobuttons path="isall" items="${fns:getDictList('allType')}" itemLabel="label" itemValue="value" htmlEscape="false" class="" οnclick=""/>

这里的radiobuttons 没有显示name和type属性,只需要在网页上查看form表单的源码,找到上述radiobuttons 的name属性的值,就可以根据上述js去获取radio的值。

参考原文链接:http://www.cnblogs.com/youyefly/p/5512185.html

发布了33 篇原创文章 · 获赞 3 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_37189727/article/details/85258210