带有jQuery的TampermonKey脚本中的视频控制
我正在使用TampermonKey脚本上的wall,该脚本将元素添加到语法中的页面中,
<div class="dplayer-setting-speed-item" data-speed="10"><span class="dplayer-label">10</span></div>
但是,当我试图将事件处理程序绑定到它的情况下,就像
$('.dplayer-setting-speed-item').on('click',()=>{
var r=$(this).attr('data-speed');
console.log(this);
console.log(r);
$('video')[0].playbackRate=r;
});
它无所作为,并为我的两个console.log()打印两个“未定义”。 如何解决?
I'm woring on a tampermonkey script that adds elements to the page in the syntax
<div class="dplayer-setting-speed-item" data-speed="10"><span class="dplayer-label">10</span></div>
However, when I'm trying to bind a event handler to it like
$('.dplayer-setting-speed-item').on('click',()=>{
var r=$(this).attr('data-speed');
console.log(this);
console.log(r);
$('video')[0].playbackRate=r;
});
it does nothing and prints two 'undefined' for my two console.log().
How to solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论