在jQuery中使用UserControl中的RadioButtonList

时间:2016-10-12 12:13:01

标签: jquery

以下是jQuery中的代码。

var randomArray = [];

While(randomArray.length != 5){
   wordsReverse(wordsArray).toString().replace(/\,/g, ' ');
   var str = createRandomText(wordsArray).toString().replace(/\,/g, ' ');
   if(randomArray.indexOf(str) < -1) {
     randomArray.push(str);
   }
}

});

这是星期一的rdlAvailability的标记

$(document).ready(function(){
$("[id^='rdlAvailability_'][type='radio']").each(function () {
    $(this).change(function(){
        var radioBtnId = this.id;
        var $this = $(this);
        radconfirm('Are you sure you want to select this slot?', function(arg){
            if (arg == true) {
                $find('<%= FindControl("txtAvailability").ClientID %>').set_value("");
            }    
            else {
                $this.siblings('input').prop('checked',true);
                var rdlAvailability = document.getElementById(radioBtnId);
                rdlAvailability.checked = false;
                $this.prop('checked', false);
            }
        }, 300, 100,"");
    })
});

如何在点击星期一或任何一天时使jQuery代码只能单次工作。我已经给了周一的加价。现在我收到4个确认消息框。它没有捕获<table id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability" class="radio1" border="0" style="color: #004B59; font-size: 11px; font-family: Arial, Sans-serif; text-align: justify"> <tr> <td><span disabled="disabled"><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_0" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL01" disabled="disabled" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_0">Slot 0</label></span></td> </tr><tr> <td><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_1" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL02" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_1">Slot 1</label></td> </tr><tr> <td><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_2" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL03" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_2">Slot 2</label></td> </tr><tr> <td><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_3" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL04" checked="checked" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_3">Slot 3</label></td> </tr> </table> 的正确可用性ID。

1 个答案:

答案 0 :(得分:1)

尝试直接绑定点击而不是每个功能

$("[id^='rdlAvailability_'][type='radio']").on("change", function()
{
  // your code here
});