0

mootools 上的负载是否会访问 html 元素?我尝试在我的代码中访问名为 class = repliesList 的 html 元素

var tabs = getElementsByClass ('repliesList'); 警报(标签);

但是 tabs 变量只打印空白,如何加入加载的 html 元素?我尝试过使用 domready,但根本没有运行,即使打印处于警报状态的东西也没有。

请帮帮我

4

2 回答 2

0

如果您使用的是 mootools 那么为什么不使用mootools 选择器

您可以通过 $$('.repliesList') 访问元素。您在代码中所犯的错误是您缺少“文档”字写document.getElementsByClass('repliesList');

但是你应该更喜欢 mootools 选择器

于 2010-12-02T04:58:18.167 回答
0
window.addEvent("domready", function() {
    // be more deffinitive in the selectors. eg all LI with class repliesList:
    var tabs = document.getElements("li.repliesList"); // will work in all versions of mootools
    // for 1.12 (old joomla) you can use $$("li.repliesList") 

    // to be faster still - if all the tabs are children of say, ul id="menu"
    var tabs = $("menu").getElements("li.repliesList");        

    // don't alert an elements collection. get FireBug or similar and:
    console.log(tabs);

    tabs.each(function(tab) {
        // do something with each tab like tab.addEvents() etc
    });
}); // end domready
于 2010-12-02T09:42:24.220 回答