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
  }
}

代码到达“执行点”,当我设置一个基本警报时,或者其他什么。

4

1 回答 1

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

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

于 2011-11-22T21:49:41.663 回答