Getting ID from asp.net runat server in jQuery

后端 未结 7 2280
执笔经年
执笔经年 2020-12-01 17:17

I\'m trying make some stuff in jQuery using ASP.NET. But the ID from runat=\"server\" is not the same as the id used in HTML.

I used to use this to get

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 17:37

    Try putting it into a variable name:

    var txtTestID = '#' + '<%=txtTest.ClientID %>';
    
    $(txtTestID).val();
    

    I'm not sure if the <%= likes being inside double quotes. I've always had mixed behaviors when not using the single quote.

提交回复
热议问题