Possible to set value in @html.label using jquery in asp.net mvc4?
asp.net, asp.net-mvc, asp.net-mvc-4, html, jquery
Solution
This statement does not output anything as you have not specified a for value:
@Html.Label("", new { id="txtStatus1" })
If you change it to give it a value i.e.
@Html.Label("a", new { id="txtStatus1" })
It outputs this:
<label for="a" id="txtStatus1">a</label>
Sridhar R is correct you can use text to set it like this:
$('#txtStatus1').text('this')
http://jsfiddle.net/bk8KZ/
You might need to add quotes and output around the argument if it is comming from your model i.e.
$('#txtStatus1').val('@Model.TicketStatus');
What is TicketStatus exactly?
Problem
i have a `@Html.Label("", new { id="txtStatus1" })` where txtstatus1 value is obtained using jquery as ` $('#txtStatus1').val(TicketStatus);` but im not able to set this value to label .