mootools上的负载是否会访问html元素? 我尝试在我的代码中访问名为class = repliesList的html元素
var tabs = getElementsByClass('repliesList'); 警报(标签);
但是标签变量只打印空白,如何加入加载的html元素? 我已经尝试过使用domready,但根本没有运行,甚至打印出警报的内容都没有。
请帮帮我
答案 0 :(得分:0)
如果您使用的是mootools,那么为什么不使用mootools selectors。
您可以通过$$('。repliesList')访问元素。你在代码中遇到的问题是你缺少“文档”一词写document.getElementsByClass('repliesList');
但你应该更喜欢mootools选择器
答案 1 :(得分: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