If you are using ASP.NET 4 see answer one. Otherwise you have to obtain ClientId from control to JS.
document.getElementById('<%=control.ClientId%>');
Not very nice since mixing HTML, JS and C#. If you could migrate to never version of ASP, migrate just for this it will save you some pain in maintaining code.