How to detect the changes in input values when it is dynamically changed. as the change on txt2 clear the value in txt1 . I need to detect that it has cleared or changed.
Onchange does not do that.
<input id="txt1" type="text" onchange="SetDefault();" onpaste="this.onchange();" oninput="this.onchange();"> <br> <input id="txt2" type="text" onchange="SetDefaultSecond();" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"> <script> function SetDefault(){ alert("Change1"); } function SetDefaultSecond(){ $("#txt1").val(''); alert("Change2"); } </script>
onpropertychangein IEs, not useful in general though). Even Mutation Observer can't be used (can detect attribute changes of an input only). Hence the only way left is to use a timed function to check, if a value has been changed.