gpt4 book ai didi

javascript - 使用 jQuery 触发 prototype.js 的更改事件

转载 作者:行者123 更新时间:2023-11-30 05:51:46 26 4
gpt4 key购买 nike

我正在处理由“更改”事件监听器激活的长 prototype.js 代码,我需要创建一个模拟“更改”事件的 jQuery 函数来激活原型(prototype)脚本。我该怎么做?

注:$('select[id="..."]').val(...).trigger('change');不激活原型(prototype)脚本

最佳答案

jQuery 的 .trigger() 仅适用于通过 jQuery 添加的事件处理程序(参见:http://api.jquery.com/trigger/)

Any event handlers attached with .on() or one of its shortcut methods are triggered when the corresponding event occurs. They can be fired manually, however, with the .trigger() method.

原型(prototype)的 .fire() 仅适用于自定义事件(参见:http://api.prototypejs.org/dom/Event/fire/)

Fires a custom event of name eventName with element as its target. Custom events must include a colon (:) in their names.

不幸的是,执行您所描述的操作的唯一方法是获取对“long prototype.js 代码”的某种引用并手动调用它。 (这取决于您所指的实现方式。)使用 javascript 不可能触发真正的“ native ”更改事件。

关于javascript - 使用 jQuery 触发 prototype.js 的更改事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14307641/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com