Javascript 我需要访问iframe视频中的一个特定元素?

Javascript 我需要访问iframe视频中的一个特定元素?,javascript,jquery,html,Javascript,Jquery,Html,我正在尝试访问页面中vimeo视频的播放按钮。因为它是一个iframe,所以我无法使用jquery获得播放按钮 以下是尝试的代码: $(".component.video.detail").on("click", ".vp-controls > button", function () { alert("triggered play button"); }); 这也不起作用: $(document).on("click", ".vp-controls > button",

我正在尝试访问页面中vimeo视频的播放按钮。因为它是一个iframe,所以我无法使用jquery获得播放按钮

以下是尝试的代码:

$(".component.video.detail").on("click", ".vp-controls > button", function () {
    alert("triggered play button");
});
这也不起作用:

$(document).on("click", ".vp-controls > button", alert("triggered play button"));

任何帮助或见解都将不胜感激。

通常,您必须访问iFrame的文档,然后在其中搜索元素

const iFrame = document.getElementById('iFrameID');
const innerDocument = iFrame.contentDocument || iFrame.contentWindow.document;

根据MattSizzle的链接,这只在同一个域中有效。由于这是一个外部Vimeo视频,您将无法访问其内部,因为跨站点脚本是一种安全违规行为。

该帖子的可能重复内容只回答了Can I,我需要有关如何使用的帮助?