$('#<%=nameLabel.ClientID%>') does not work when in .js file and works when in script is in the page

后端 未结 5 1311
再見小時候
再見小時候 2021-01-28 19:08

$(\'#<%=nameLabel.ClientID%>\') is being used in my script for jquery.

When this is in ... block in tha page , it works fine ,as its a content page i

5条回答
  •  滥情空心
    2021-01-28 19:53

    External javascript files are not served by the ASP.NET engine, so any server side tags such as <%= ... %> will not work. You could apply a css class to the element and use a CSS selector:

    $('.nameLabel')
    

提交回复
热议问题