Javascript 试图锁定自定义控件,但当页面中有多个控件时出现问题
我有一个自定义控件,可以三次加载到页面上 自定义控件由文本框和自定义日期选择器控件组成 我正在尝试锁定所有日期选择器控件 我在控制中尝试了以下代码Javascript 试图锁定自定义控件,但当页面中有多个控件时出现问题,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我有一个自定义控件,可以三次加载到页面上 自定义控件由文本框和自定义日期选择器控件组成 我正在尝试锁定所有日期选择器控件 我在控制中尝试了以下代码 $(document).ready(function() { debugger; var mySelector = '#' + $('[id$=\'_SignatureNonPoliceControl\']', $(this)).attr('id'); $(mySelector.replace('_SignatureNonPo
$(document).ready(function() {
debugger;
var mySelector = '#' + $('[id$=\'_SignatureNonPoliceControl\']', $(this)).attr('id');
$(mySelector.replace('_SignatureNonPoliceControl', '_SignatureDatePicker_DatePickerControl')).BaseControlPlugin(BaseControlMethodsEnum.SetLocked, true);
});
但是,这只会锁定第一个,并执行三次
我的控制是这样设置的
<uc8:SignatureCaptureNonPolice ID="DetaineeSignature" runat="server" Caption = "Person's Signature to Comments " RetainValueWhenDisabled="true" />
<uc1:GenericDropDownList Caption="Reason For Not Signing " ID="DetaineeReasonNotSignedGenericDropDownList" runat="server" />
<uc8:SignatureCaptureNonPolice ID="AppropriateAdultSignature" runat="server" Caption = "Appropriate Adults<br />Signature to Comments " RetainValueWhenDisabled="true" />
<uc8:SignatureCaptureNonPolice ID="InterpreterSignature" runat="server" Caption = "Interpreter's Signature<br />to Comments " RetainValueWhenDisabled="true" />
我必须使用$(这个)吗。我对这件事很陌生
救命啊
谢谢
Kev.你的约会挑选者有共同的职业吗?您可以选择以下选项:
$('.className')
另一个选项是在一个选择器中用逗号分隔所有ID:
$('#firstID,#secondID,#thirdID')
那么我假设您想对它们应用一个锁定的类
$('.className').addClass("locked");
通过这样做,您可以轻松地检查逻辑:
if (this.hasClass("locked") {
// this is locked.
}
阅读有关选择器的更多信息: