Wednesday, January 9, 2013

Accessing Multiple Controls in Jquery


Let's say we have two text boxes

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

Now we need to set the text of both of the text boxes.

<script type="text/javascript">
$(document).ready(function () {
$("[id*='TextBox']").val("Same Value");
});
</script>

In the above jquery code text boxes which contains "TextBox" in id attribute will change the text to "Same Value".


No comments:
Write comments
Recommended Posts × +