ASP DDL jquery 选择器

发布于 2024-12-10 18:04:12 字数 315 浏览 2 评论 0原文

当服务器处理控件时,下拉列表 ID 会被修改,因此它们不再是 SimpleDDL,而是变成 cph_main_SimpleDDL 或类似的东西。

我有一个采用 DDL ID 的 jQuery 方法,但当 DDL 名称更改时它不起作用。

我可以使用什么 JS 函数来拆分 ID 名称并仅获取 SimpleDDL 部分?

我知道如何通过这样做来选择名称的这个特定部分:

$('select[id$=SimpleDDL]')

但我只需要获取 ID 名称的一部分并将其分配给一个变量。

谢谢!

The drop down lists IDs get modified when the control is handled by the server so instead of SimpleDDL they become cph_main_SimpleDDL or something like that.

I have a jQuery method that takes the DDL ID, but it doesn't work as the DDL names change.

What JS function can I use to split the ID name and get just the SimpleDDL part?

I know how to select this particular part of the name by doing this:

$('select[id$=SimpleDDL]')

but I need to just get a part of the ID name and assign it to a variable.

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光下慵懒的猫 2024-12-17 18:04:12
  1. ,当我们使用母版页时,控件的ID会发生变化,如您所提到的,因此我们可以获得控件的ID,例如'<%=SimpleDDL.ClientID %>'

  2. 如果您使用.NET 4.0 则有一个控件属性 ClientIDMode="static",因此这将保留您提到的控件 id。

  1. In .NET when we use master page Id of control changes as you mentioned so we can get ID of control like '<%=SimpleDDL.ClientID %>'

  2. If you are using .NET 4.0 then there is an property of control ClientIDMode="static" so this will remain you control id as mentioned.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文