This article mainly introduces JS or jquery to obtain ASP.net server control ID method, this article introduces a method to solve the use of JS to obtain ASP.net control in the browser to generate HTML tags corresponding to the ID, the need for friends can refer to the
In the use of JS in asp.net, JS get dom elements, often not get, this is because the method is incorrect, now introduce a method to solve how to use JS to obtain ASP.net control in the browser to generate HTML tags corresponding to the ID
1. Get the ID of the label generated by the server-side control on the browser side, that is, the client HTML tag ID of the server control
The ClientID property of the server-side control allows you to obtain the corresponding ID value in the browser, the client HTML tag, for the following
The code is as follows:
The code is as follows:
<%= Newsid.clientid%>
2. Get the appropriate DOM elements through the DOM
It can be obtained through js,document or jquery, and here's a jquery example
The code is as follows:
var newsId = $ ("#<%= newsid.clientid%>");
3. Working with DOM elements
Now that you've got the elements you want to manipulate, then you can do the corresponding operation, and then you will see, start "Do as you please" ~ ~ ~
Note < > : More Wonderful tutorials please focus on Triple programming