Mootools:相同的函数在单个元素上使用时会生成错误吗?
这是我得到的错误:
Uncaught TypeError: Object #
这是 domready 函数中的代码:
$$('.accordion_content').slide('hide');
$$('.accordion_header').addEvent('click', function(e) {
this.getParent().getElement('.accordion_content').slide('toggle');
this.toggleClass('header_highlight');
});
// set horizontal slide for sidebar
$('priceNPay').slide('hide', 'horizontal');
$('theSidebar').style.backgroundColor = 'green';
// THIS IS WHERE IT ERRORS OUT... WHY!?
$('theSidebar').addevent('click', function(e) {
this.getElement('priceNPay').slide('toggle');
this.toggleClass('header_highlight');
});
第一块代码工作正常。在具有相关类的所有
元素上疯狂切换。第二块代码隐藏
,更改
的颜色...但在尝试执行 addEvent 时出错
。为什么啊!!!???
我认为唯一区别的结构是相关的...如果它不起作用:
<div id='someName'>
<h1>title text</h1>
<div id='someOtherName'> (on the sidebar, this is an 'article' element)
<p>some text</p>
</div>
</div>
我没有遵循的是为什么它会隐藏,但随后不会瞄准切换...?
谢谢帮。
写!
this is the error i get:
Uncaught TypeError: Object #<HTMLDivElement> has no method
this is the code in the domready function:
$('.accordion_content').slide('hide');
$('.accordion_header').addEvent('click', function(e) {
this.getParent().getElement('.accordion_content').slide('toggle');
this.toggleClass('header_highlight');
});
// set horizontal slide for sidebar
$('priceNPay').slide('hide', 'horizontal');
$('theSidebar').style.backgroundColor = 'green';
// THIS IS WHERE IT ERRORS OUT... WHY!?
$('theSidebar').addevent('click', function(e) {
this.getElement('priceNPay').slide('toggle');
this.toggleClass('header_highlight');
});
the first chunk of code works fine. toggles like mad on all <div>
elements with the relevant class. the second chunk of code hides the <div>
, changes the <div>
's colour...but errors out when trying to do the addEvent
.
WHYYYY!!!????
the structure of the the only difference i can think would be relevant...if it didn't work:
<div id='someName'>
<h1>title text</h1>
<div id='someOtherName'> (on the sidebar, this is an 'article' element)
<p>some text</p>
</div>
</div>
what i'm not following is why it'll hide, but then won't target for the toggle...?
thanks gang.
WR!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用
addevent
而不是addEvent
。You are using
addevent
instead ofaddEvent
.