Fire onchange event for TextBox when readonly is true

前端 未结 4 1710
爱一瞬间的悲伤
爱一瞬间的悲伤 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:52

    you can do like this

    function setValueOfTextBox()
    {
        var myElement = document.getElementById("textboxid");
        myElement.value = "hello";
        //following code fire change event for you text box
        if (myElement.onchange) 
             myElement.onchange();
    }
    

提交回复
热议问题