简体   繁体   中英

Detect Label Change Using - jQuery

I have a lookup field so based on the drop down change the lookup field value changes

 var name; $("#tdf_15").on('DOMSubtreeModified', function () { name = $(this).html(); alert(name); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="tdf_15" class="cell dc" style="background-color: rgb(255, 253, 221);">Dileep Thomas</div> 

So this snippet will alert whenever the lookup field changes , but the alert is working for three times initially when the field is blank and once it is have a value then alert will work for four times at each time we change the drop down. I need to have the alert for only one time also i need to check the value in the variable( name ) is changed or not.

Many thanks in advance if anyone can help me !!

Change DOMSubtreeModified to change

var name;
$("#tdf_15").on('change', function () {
   name =  $(this).html();
   alert(name);
});

I think i got the solution i searched the developers google Stackoverflow itself

The below link 4th answer solved this isssue

how to fire event on label text change

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM