可以使用没有ID的jQuery吗?

发布于 2025-02-13 21:48:14 字数 506 浏览 0 评论 0 原文

我正在研究一段代码,在该代码中,似乎jQuery通过ID 访问一个元素,而没有 实际上具有ID的元素。以表格这是我所拥有的:

@Html.CheckBoxFor(Model => Model.IsEBSToBeCreated, new { disabled = "disabled", @checked = "checked" })

周围< div> 中没有ID,但是在脚本中,我看到了:

if ($("#ddlStatus option:selected").text() == 'Active') {
                $("#IsEBSToBeCreated").prop("disabled", false);
            }

如何使用 #isebstobecreated 而没有匹配的ID在 .cshtml 文件本身中。

I am working on a piece of code where it appears as if though jQuery accesses an element by ID without the element actually having an ID. In the form this is what I have:

@Html.CheckBoxFor(Model => Model.IsEBSToBeCreated, new { disabled = "disabled", @checked = "checked" })

No IDs in the surrounding <div> but in the script I see this:

if ($("#ddlStatus option:selected").text() == 'Active') {
                $("#IsEBSToBeCreated").prop("disabled", false);
            }

How is jQuery using #IsEBSToBeCreated without a matching ID in the .cshtml file itself.

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

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

发布评论

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

评论(1

2025-02-20 21:48:15

使用@madreflection的提示,我查看了文档, html.checkboxfor ,实际上它可以生成一个输入元素 #isebstobecreated id。

谢谢

Using the hint from @madreflection I looked at the documentation and markup generated by the Html.CheckBoxFor and indeed it generates an input element with an #IsEBSToBeCreated ID.

Thank you

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