javascript - 无法自定义交互式 JavaScript 内容

标签 javascript php plugins moodle

我们使用 Moodle 3.5 版本并使用 H5P 插件进行交互式视频。我们需要在提交按钮上添加另一个操作

请检查链接https://h5p.org/interactive-video 。回答问题后,将出现如下所示的摘要屏幕:

Summary screen

<script>

function checkclick()
{
    $(document).ready(function(){

        $(".h5p-interactive-video-endscreen-submit-button").click(function(){
            alert("submitted");

        });
     });
}

$(document).ready(function(){
    iframe=H5P.$body.contents();
    iframe.find(".h5p-interactive-video-endscreen-submit-button").click(function(){
          alert("hello");
    });
});

// H5P.$body.contents().find(".h5p-interactive-video-endscreen-submit-button")

// $(document).ready(function(){
//        var button= H5P.$body.contents().find(".h5p-interactive-video-endscreen-submit-button");
//     button.attr("id","myclass");
//        console.log(button);
// });

</script>

已尝试上述技术来获取单击按钮时的警报,但没有成功。

最佳答案

更改此:

$(document).ready(function(){
    iframe=H5P.$body.contents();
    iframe.find(".h5p-interactive-video-endscreen-submit-button").click(function(){
      alert("hello");
    });
});

对此:

$(document).ready(function(){
    iframe=H5P.$body.contents();
    $(document).on('click',function(){
        if(iframe.find(".h5p-interactive-video-endscreen-submit-button").is(":hover")){
          alert('hello');
        }
    });
});

如果无法检测到元素点击并且它有效,我通常会这样做。

关于javascript - 无法自定义交互式 JavaScript 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57908738/

相关文章:

javascript - 从同一页面上的 URL 链接到特定的 Twitter Bootstrap 选项卡

javascript - 自定义谷歌自定义搜索引擎。特别是更改标题字体

javascript - 我怎样才能使背景图像适应主分区?

php - PHP 或 Jquery 中不存在值时的条件语句

php - 如何在 joomla 组件中包含 css 和 jquery

grails - 从本地 Grails 插件中排除依赖项

javascript - 使用通过自定义数据属性检索的选择器在音频播放时显示目标 div

php - MySQL - 只选择包含序列化数据的单元格

jquery 停用插件

plugins - 基于Python的浏览器插件?