What's the best way to deal with ASP.NET's ClientID

后端 未结 4 1840
闹比i
闹比i 2021-01-15 03:55

I\'m trying to find the best way to deal with the way that ASP.NET prepends a value to any element that is created with runat=\"server\", without having to reso

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 04:20

    You can use the jQuery ends with selector:

    $('input[id$="myServerId"]')

    But remember, that kind of selector is a lot slower than selecting directly with the id with <%= id.ClientID %>.

    http://jsperf.com/id-vs-ends-with

提交回复
热议问题