Reputation:
I have a MVC web application with master layout and views based on that layout.And I need to display some text in a label which is in the master layout.
And my javascript function is in the child view.
here is my master page.
<body onload="setInterval('LayOutHandler.DiplayClock()', 1000);">
<div id="notify">
@Html.Label("hi", new { id="lblnotify"})
</div>
</body
And here is my javascript function in the view..
getCustomerDetails: function (customerPhoneNumber) {
$("#lblnotify").val("calling");
},
don't mind the javascript function, its a call back function which fires from signalr.And it works fine.The issue is I can't change the text of the lblnotify from this function. It identifies the lable object, but text is not changing...
How can I slove this???
Upvotes: 1
Views: 55
Reputation: 62488
Label is rendered in html as:
<label id="lblnotify">hi</label>
and for changing text between its tags, you need to use text()
:
$("#lblnotify").text("calling");
Upvotes: 1