Hello folks,
BTW this is the best website for learning Javascript.
Basically I have bunch of label controls in a table element (in a row).
When user clicks a button, I would like to clear the text of all those label elements. What is the best way to do this.
Here is my thought and help me out here.
With the combination of getElementByID and getElementByTagName we can get all the elements under an ID
Like the following way.
var allLabels = document.getElementById(“someID”).getElementsByTagName(“Label”);
But in my situation, the Labels are in <td> elements. How can i reach all the Labels? Any suggestions please?
Thanks
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ReachAllLabelControls();" />
<table border="1">
<tr>
<td >
<asp:Label ID="LabelCountAdvs" runat="server" Text=""></asp:Label>
</td>
<td>
<asp:Label ID="LabelCountSwaps" runat="server" Text=""></asp:Label>
</td>
<td>
<asp:Label ID="LabelCountBonds" runat="server" Text="">bonds</asp:Label>
</td>
<td>
<asp:Label ID="LabelCountDNs" runat="server" Text="">DN's</asp:Label>
</td>
<td>
<asp:Label ID="LabelCountDeposits" runat="server" Text="">Deposits</asp:Label>
</td>
<td>
<asp:Label ID="LabelCountMBS" runat="server" Text="">MBS</asp:Label>
</td>
<asp:Label ID="LabelGl" runat="server" Text="">GL</asp:Label>
</td>
</tr>
</table>
</div>
</form>
<script language="javascript" type="text/javascript">
function ReachAllLabelControls() {
// var pars = document.getElementById(
}
</script>
</body>
</html>