gpt4 book ai didi

jquery - 禁用下拉列表项 jquery 不起作用

转载 作者:行者123 更新时间:2023-12-03 22:31:24 26 4
gpt4 key购买 nike

我想使用 jquery 禁用下拉列表项。索引值为-1,值为--------内部--------。我一一尝试了以下语法(解决方案是类似问题的答案)。他们都没有工作。我正在使用 IE8。

var value="------- Internal -------";
$("[id*='ChildOrganizationDropDownList'] option[value=" + value + "]").prop('disabled','disabled');
$("#ChildOrganizationDropDownList option[value=" + value + "]").prop('disabled','disabled');
$("[id*='ChildOrganizationDropDownList']").option('------- Internal -------').prop('disabled',true);
$("id*='ChildOrganizationDropDownList' option[value='------- Internal -------']").prop('disabled','disabled');
$("[id*='ChildOrganizationDropDownList']").option("[value*='------- Internal -------']").prop('disabled', true);
$("[id*='ChildOrganizationDropDownList']").attr("disabled",$(_this.CustomerNameDropDownList).find("option[value='------- Internal -------']"));

设计师:Aspx

<div class="selectionControls">
<asp:CheckBox ID="chkSubcontracting" runat="server" Text="Subcontracting" Enabled="true" />
<asp:HiddenField ID="SubcontractingHiddenField" runat="server" />
<div class="subSelectionControl" id="AllowSubcotractingSelection" style="display: none;">
<div class="subContractingControls">
Parent BU:
<span>
<div class="subContractingControls">
Supplier <em class="mandatoryIndicator">*</em>:
<span>
<asp:DropDownList ID="ChildOrganizationDropDownList" runat="server" Width="200px" />
<asp:HiddenField ID="IxChildOrganizationHiddenField" runat="server" />
</span>
</div>
</div>
</div>

ASPX.cs

public Dictionary<int, string> ChildOrganizations
{
set
{
var result = value;
result.Add(0, "Select Supplier");
ChildOrganizationDropDownList.DataSource = result;
ChildOrganizationDropDownList.DataTextField = "value";
ChildOrganizationDropDownList.DataValueField = "key";
ChildOrganizationDropDownList.DataBind();
ChildOrganizationDropDownList.SelectedValue = "0";


}
}

最佳答案

我使用了each,它对我有用:https://jsfiddle.net/pz9curkb/1/

<select id="ChildOrganizationDropDownList">
<option value="Default">Default</option>
<option value="A">A</option>
<option value="B">------- Internal -------</option>
<option value="E">E</option>
</select>


$("#ChildOrganizationDropDownList option").each(function(){
if($(this).text() === "------- Internal -------"){
this.disabled = true;
}
});

请注意,在此解决方案中我使用了 this 而不是 $(this),这意味着我使用了 javascript 提供的禁用选项

关于jquery - 禁用下拉列表项 jquery 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29559930/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com