带有jQuery的TampermonKey脚本中的视频控制

发布于 2025-01-21 13:00:55 字数 530 浏览 0 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文