I am developing a web page using asp net web forms.
In javascript I can loop through my components;
for (var i = 2; i <= 10; i++) {
$("#textbox" + i).get(0).style.display = 'none';
}
However when I set runat="server" for components, I need to access;
$("#<%=textbox1.ClientID %>").get(0).style.display = 'none';
$("#<%=textbox2.ClientID %>").get(0).style.display = 'none';
My question is, is there a way to loop through components which are set runat="server" in javascript?
You can assign cssClass to the elements. That class names will not change while rendering.
Then you can use $(".classname").hide()
to hide all the elements with a particular class name.
You can loop them as well
$(".classname") each(function () {
$(this).get(0)//if you need dom element
});