如何在 Mootools 中为具有特定元素 ID 的特定标签/元素触发事件?

发布于 2024-12-17 15:43:52 字数 520 浏览 5 评论 0原文

如何在 Mootools 中为具有特定元素 ID 的特定标签/元素触发事件?

我有这个:

<a href="youtube-clip...etc" rel="rokbox" id="video_popup" style="display: none;">Video</a>

这个 rel="rokbox" 意味着该元素将由 Mootools RokBox 模式框使用,但我隐藏了链接。

现在,我添加了以下代码:

window.onload = function() {
  if(document.readyState == 'complete') {
    // point of execution
    // here I want to trigger the "a" element I've wrote up before
  }
}

代码到达“执行点”,此时我设置了基本警报或其他任何内容。

How to trigger an event in Mootools for a specific tag/element with a specific element ID?

I have this:

<a href="youtube-clip...etc" rel="rokbox" id="video_popup" style="display: none;">Video</a>

This rel="rokbox" means that the element will be used by the Mootools RokBox modal box, but I've hidden the link.

Now, I've added this code:

window.onload = function() {
  if(document.readyState == 'complete') {
    // point of execution
    // here I want to trigger the "a" element I've wrote up before
  }
}

The code reaches until the "point of execution", when I set a basic alert, or whatsoever.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2024-12-24 15:43:52
window.addEvent('domready', function() {
    $('video_popup').fireEvent('click');
});

请注意使用 addEvent/domready,这是添加页面准备好后必须执行的函数的正确方法。

window.addEvent('domready', function() {
    $('video_popup').fireEvent('click');
});

Note the use addEvent/domready, which is the proper method to add a function which must execute once the page is ready.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文