jquery修改获取radio的选中项

<input id="txtBeginDate" onclick="$('#divDate').css({'top':$('#txtBeginDate').offset().top+'px','left':$('#txtBeginDate').offset().left+'px'})" style="170px;padding:7px 10px;border:1px solid #ccc;margin-right:10px;"/>
            <label><input type="radio" name="sotype" value="0" checked/>商城</label>
            <label><input type="radio" name="sotype" value="1" />团购</label>
            <label><input type="radio" name="sotype" value="2" />行业</label>
            <button type="button" name="appidsubmit" onclick="chaxun()" value="true" class="btnGreen vm" ><strong>查询</strong></button>
            <script>
            $(document).ready(function(){
                var type = 1;
                if(type==1){
                    $('input[name="sotype"]:eq(1)').attr("checked",'checked'); 
                }else if(type==2){
                    $('input[name="sotype"]:eq(2)').attr("checked",'checked'); 
                }
            });
      </script>

 $('input[name="sotype"]:checked').val();//获取选中的值

原文地址:https://www.cnblogs.com/zonglonglong/p/5467845.html