jquery给net里面的RadioButtonList添加选项改变事件

时间:2022-01-18 01:30:28

<script type="text/JavaScript" src="../../../JS/jQuery-1.4.1.min.js"></script>
<script type="text/javascript">
    $(function () {

//获取页面加载时RadioButtonList选中的值

var SelectVal = $(":input:radio[@name='#<%= rblState.ClientID%> > input'][checked]").val()

//初始化判断

if (SelectVal != "0") {
            $("#trLogisticsInfo").css("display", "block");
        }
        else {
            $("#trLogisticsInfo").css("display", "none");
        }

//添加change事件

$("#<%=rblState.ClientID %>").change(function () {

SelectVal = $(":input:radio[@name='#<%= rblState.ClientID%> > input'][checked]").val()         
            if (SelectVal != "0") {
                $("#trLogisticsInfo").css("display", "block");
            }
            else {
                $("#trLogisticsInfo").css("display", "none");
            }

});
    });
</script>