如何使用“load”访问 HTML 元素在 mootools 核心?

发布于 2024-10-05 18:05:51 字数 235 浏览 8 评论 0原文

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

var tabs = getElementsByClass('repliesList'); 警报(选项卡);

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

请帮帮我

whether the load on the mootools will access the html element?
I try to access the html element named class = repliesList, in my code there

var tabs = getElementsByClass ('repliesList');
alert(tabs);

but tabs variable print only blank, how to join loaded html element?
I've tried using domready, but does not run at all, even printing something that is on alert was not.

please help me out

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

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

发布评论

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

评论(2

鹿童谣 2024-10-12 18:05:51

如果您正在使用 mootools 那么为什么不使用 mootools 选择器

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

但你应该更喜欢 mootools 选择器

if you are using mootools then why don't you are using mootools selectors.

you can access element by $$('.repliesList'). What you wronn in you code is you are missing "document" word write document.getElementsByClass('repliesList');

But You should prefer mootools selectors

好久不见√ 2024-10-12 18:05:51
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文