/ Published in: ASP
In the examples, below, Step1 is the id given to the element. If the element is set to runat="server", when it is rendered on the page, the id will change dynamically to something like ctl00$PlaceHolderMain$Step1. But the actual value may change. To make sure we capture the correct value to manipulate the element in javascript or CSS, use the technique below. Note that this code will need to live on the same page as the element, not in an external js or css file.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<%--jQuery example --> <script> $('#<%=Step1.ClientID %>').someFunction(); </script> <%--CSS example --> <style> #<%=Step1.ClientID %> {some style...} </style>