由Javascript触发的onChange [英] onChange triggered by Javascript

查看:44
本文介绍了由Javascript触发的onChange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在尝试创建一个应用程序,我可以从页面中提取信息并将其放入Excel中。


现在的问题是该页面是使用jQuery和Ajax构建的。

因此,当您在选择框中选择一个选项时,内容会发生变化。


现在的问题是,当我使用脚本选择选项时,内容不会改变。


因此手动选择更改内容,脚本选择不会更改内容。


有没有办法可以触发元素的onChange事件让它知道它已被更改?

Hello,

I''m trying to create an application where I can extract information from a page and put it into Excel.

Now the problem is that the page has been constructed using jQuery and Ajax.
So when you select an option in a select-box, the contents change.

Now the problem is that when I select the option using a script, the contents don''t change.

So manually select changes the content, script select doesn''t change the content.

Is there a way I can trigger the onChange event of an element to let it know it has been changed?

展开 | 选择 | Wrap | 行号

推荐答案

我刚注意到通过调用元素本身的onchange()它会触发onchange事件。


所以这段代码触发事件。
I just noticed that by calling the onchange() on the element itself it triggers the onchange event.

So this code triggers the event.
展开 | 选择 < span class =codeDivider> | Wrap | 行号



change事件:

控件失去输入焦点,并且自获得焦点后其值已被修改。应在事件类型模糊之前调度此事件类型。
change Event:
A control loses the input focus and its value has been modified since gaining focus. This event type shall be dispatched before the event type blur.



如果您手动创建一个事件,您执行document.createEvent(),然后在您选择的元素(Element.dispatchEvent())上调度它。但为什么你需要走那么远?


除了你的HTML无效之外。没有jQuery ***属性

if you manually create an event you do document.createEvent() and then dispatch it at the element of your choice (Element.dispatchEvent()). but why would you need to go that far?

besides that your HTML is invalid. there are no jQuery*** attributes


就像我之前说的那样,这是代码来自一个网站,我正在试图获取数据。因此我无法更改此代码。


由于某种原因,当我手动选择一个选项时,内容会发生变化,尽管没有onchange事件。
Well like I said earlier, this is code is coming from a website where I''m trying to get data off. So I can''t change this code.

And for some reason when I select an option manually the content changes, although there is no onchange event.


这篇关于由Javascript触发的onChange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆