有没有办法使用 JavaScript 手动重置 onchange 事件?
这可能吗?我尝试设置 selectedIndex
但这不起作用。
我遇到的是触摸屏设备上的 onChange 事件的问题。从下拉列表中进行选择的 onChange 事件第一次工作正常,但当我再次调用表单时似乎没有重置,即使我重置了表单本身。
问题在于,第一个下拉列表上的选择(在第一个下拉列表之后)取决于调用函数来生成下一个选择下拉列表的 onChange 事件。但是,在设备本身上,如果在第一个框中重新选择该项目,则 onChange 事件似乎不会触发。很难理解,但我想如果我可以重置该选择框元素的 onChange 事件,那么 onChange 事件将再次正确触发。
Is this possible? I tried setting selectedIndex
but that didn't work.
What I have is a problem with an onChange event on a touchscreen device. The onChange event with a selection from a dropdown works fine the first time, but doesn't seem to reset when I call the form again, even though I reset the form itself.
The problem is that the selections on the first dropdown, after the first one, depend on the onChange event calling a function to generate the next select dropdown. However, on the device itself, the onChange event doesn't seem to trigger, if the item is re-selected in the first box. Difficult to understand, but I thought if I could reset the onChange event for that select box element, then the onChange event would fire properly again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想触发 onchange 处理程序吗?
document.getElementById('yourelement').onchange()
。You want to trigger the onchange handler?
document.getElementById('yourelement').onchange()
.