urizark
urizark

Reputation: 148

Possible to use jQuery without IDs?

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.

Upvotes: -1

Views: 31

Answers (1)

urizark
urizark

Reputation: 148

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

Upvotes: 1

Related Questions