Getting ID from asp.net runat server in jQuery

后端 未结 7 2275
执笔经年
执笔经年 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:43

    To avoid issues with rendered ID's, use a class instead. This won't change during rendering:

    function contatoModal() {
    
    //alert("Test");
    
    alert($(".txtTest").val());
    
    }
    

    HTML:

    < input runat="server" id="txtTest" value="test" class="txtText" />
    

提交回复
热议问题