简体   繁体   English

更改事件属性的值

[英]Changing value of event property

I trigger mousewheel event on one element and then I dispatch it to another element. 我在一个元素上触发mousewheel事件,然后将其分派到另一个元素。 It works perfectly fine, but now I am wondering if it is possible to change one property of event object to something else before dispatching? 它工作得很好,但是现在我想知道是否可以在调度之前将事件对象的一个​​属性更改为其他属性?

I tried with this code, but obviously it does not work: 我尝试使用此代码,但显然不起作用:

event.deltaY = 0;

el.dispatchEvent(new event.constructor(event.type, event));

As mentioned in the comments, the deltaY property is read-only. 如评论中所述,deltaY属性是只读的。 You're best bet would be to just create a variable that you can set and call upon when you need it. 最好的选择是创建一个变量,可以设置该变量并在需要时调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM