如何在事件监听器中传递 'this' 参数?-灵析社区

全能人才

function myFunction(_this, e) { console.log(_this, e); } document.querySelector("#i").addEventListener("keydown", function (event) { myFunction(this, event); }); ![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241023/73108e024f5be48e95d53c01ca7bb55e.png)

阅读量:1

点赞量:0

问AI