Fire onchange event for TextBox when readonly is true

前端 未结 4 1720
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 03:35

I am trying to have some functionality on change of a textbox which is readonly. But when I am trying to update the textbox using javascript, the change event is not firing

4条回答
  •  礼貌的吻别
    2021-01-19 03:38

    Well you have to do this way: http://jsfiddle.net/kmvSV/1/

     $(document).ready(function () {
       $('input[id$=_txtTest]').bind("change", function () {
         alert($(this).val());
       });
       $('button').bind("click", function () {
         $('input[id$=_txtTest]').val('hello').trigger('change');
       });
     });
    

提交回复
热议问题