javascript - How do you monitor a read only input in jquery? The .change() method doesnt work as it only works for non read-only inputs -
if have line of code in html file:
i cannot use code update contractlengthdisplay because read only:
$("#contractlengthdisplay").change(function(){ alert(1); }); is there alternative .change() method if input read only? thanks!
use .trigger("change") notify listener
$("#contractlengthdisplay").on("change", function() { // attach listener console.log( this.value ); }); $("#contractlengthdisplay") .val("bbbbb") // change value .trigger("change"); // , notify listener triggering event <script src="https://code.jquery.com/jquery-3.1.0.js"></script> <input id="contractlengthdisplay" value="aaaaa" readonly>
Comments
Post a Comment