I'm trying to fire a function when the label text changes. This is my code
$("#frameItemCode").change(function (e) {
alert("Changed");
});
#frameItemCode
is my label id, but the event isn't firing. I have tried examples given before but they hasn't helped me.This is my html
<div class="input-group">
<span class="input-group-addon" @*style="width: 120px;"*@>Item Group</span>
<label class="input-group-addon" @*style="width: 120px;"*@ id="frameGroupCode"></label>
<input class="form-control" type="text" id="frameGroupName" style="">
</div>
To dynamically update the Label widget, we can use either config(**options) or an inline configuration method such as for updating the text, we can use Label["text"]=text; for removing the label widget, we can use pack_forget() method.
Use the textContent property to change the text of a label element, e.g. label. textContent = 'Replacement label text' . The textContent property will set the text of the label to the provided string, replacing any of the existing content. Here is the HTML for the examples in this article.
Depending on which browsers you need to support, you can use MutationObserver:
var observer = new MutationObserver(
function (mutations) {
alert('Label was changed!');
}
);
observer.observe(document.querySelector('#frameGroupCode'), { childList: true });
Example jsFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With