jquery 获取radio被选中的值


<html>

<head>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
</head>

<body>

    <div id="wrap">
        <input type="radio" name="payMethod" value="1" />支付宝
        <input type="radio" name="payMethod" checked value="2" />微信
    </div>

    <script>
        
        /** 获取被选中按钮的值 **/
        var val_payPlatform = $('#wrap input[name="payMethod"]:checked ').val();

        console.log(val_payPlatform);
        alert(val_payPlatform);
        
    </script>
    
</body>
</html>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM