I have a radiobutton list and on click on the radio button item I have to change the text of its label. But for some reason it\'s not working. Code is below:
try this
$("label").html(your value);
or $("label").text(your value);
$('#<%= lblVessel.ClientID %>').html('New Text');
ASP.net Label will be rendered as a span in the browser. so user 'html'.
<asp:RadioButtonList ID="rbtnType" runat="server">
<asp:ListItem Value="C">Co</asp:ListItem>
<asp:ListItem Value="I">In</asp:ListItem>
<asp:ListItem Value="O">Out</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="lblLabelName" runat="server"></asp:Label>
<script type="text/javascript">
$(document).ready(function() {
$("#<%=rbtnType.ClientID%>").change(function() {
var rbvalue = $("input[@name=<%=rbtnType.ClientID%>]:radio:checked").val();
if (rbvalue == "C") {
$('#<%=lblLabelName.ClientID %>').html('text1');
} else if (rbvalue == "I") {
$('#<%=lblLabelName.ClientID %>').html('else text2');
} else if (rbvalue == "O") {
$('#<%=lblLabelName.ClientID %>').html('or elsethistext');
}
});
});
</script>
I just went through this myself and found the solution. See an ASP.NET label server control actually gets redered as a span (not an input), so using the .val() property to get/set will not work. Instead you must use the 'text' property on the span in conjuntion with using the controls .ClientID property. The following code will work:
$("#<%=lblVessel.ClientID %>").text('NewText');
lable value $('#lablel_id').html(value);
we have to find label tag for attribute value based on that.we have replace label text.
Script:
<script type="text/javascript">
$(document).ready(function()
{
$("label[for*='test']").html("others");
});
</script>
Html
<label for="test_992918d5-a2f4-4962-b644-bd7294cbf2e6_FillInButton">others</label>
You want to more details .Click Here