0
 $(document).ready(function () {

        $("#Button_Edit").click(function () {
            var radio1 = $("#GridView_Customer_Project_List:radio[id^='RadioButton_Select']");
            if (radio1.is(':checked') == true) {
                alert("Selected");

            }
            if (radio1.is(':checked') == false) {
                alert("Not selected");                 
            }             

        });

    });

在上面的代码中总是不会选择警报消息,我想同时验证

4

2 回答 2

1

我认为您没有正确选择 GridView。试试这个:

var count=$('table[id*="GridView_Customer_Project_List"] input[type="radio"]:checked').length;
if (count > 0){
 alert ('Selected');
}
else
    alert('Not Selected');
于 2013-10-24T06:32:43.447 回答
0

试试下面的代码

$(document).ready(function () {

    $("#Button_Edit").click(function () {
        var radio1 = $("#GridView_Customer_Project_List:radio[id^='RadioButton_Select']");
        if (radio1.is(':checked') == true) {
            alert("Selected");

        }
       else
        {

        if (radio1.is(':checked') == false) {
            alert("Not selected");                 
        }             
        }
    });

});
于 2013-10-24T06:10:55.477 回答