gpt4 book ai didi

javascript - dropdownlist 选定的索引选项不适用于 JavaScript

转载 作者:行者123 更新时间:2023-12-02 20:05:52 25 4
gpt4 key购买 nike

我使用的是asp.net下拉列表,它包含5个值,示例代码如下

<asp:DropDownList ID="ddlSampledropdown" runat="server" Width="250px">
<asp:ListItem Value="0" title="--Select--">--Select--</asp:ListItem>
<asp:ListItem Value="1" title="Alpha">Alpha</asp:ListItem>
<asp:ListItem Value="2" title="Bravo">Bravo</asp:ListItem>
<asp:ListItem Value="3" title="Charlie">Charlie</asp:ListItem>
<asp:ListItem Value="4" title="Delta">Delta</asp:ListItem>
<asp:ListItem Value="5" title="Echo">Echo</asp:ListItem>
</asp:DropDownList>

我想将下拉列表设置为禁用并将所选文本设置为 alpha 我如何在 ASP.NET 2003 中的 javascript 的帮助下做到这一点

我将其设置为禁用,但无法设置下拉列表所选值

最佳答案

使用 JQuery,选择 Alpha:

$("#ddlSampledropdown").val('1');

并禁用该控件:

$("#ddlSampledropdown").attr("disabled", true);

来源:

Change the selected value of a drop-down list with jQuery

Disable drop down box on radio button click

关于javascript - dropdownlist 选定的索引选项不适用于 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7428333/

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