且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数据分配给输入文本框时,输入文本框 onchange 不会触发

更新时间:2023-01-25 08:38:31

您可以在通过更改值后使用 document.getElementById("txt").onchange(); 从代码中触发 onchange代码

you can fire onchange from code using document.getElementById("txt").onchange(); after the changing the value through code

更新

更改您的 set 函数以获取文本框的 id

change your set function to take the id of the text box

function set(textboxid)
{
    var tb = document.getElementById(textboxid);
    tb.value++;
    tb.onchange();
}