我拼凑了一些工作了几年的 mootools 手风琴代码,但突然间我注意到 Firefox 破坏了它——在 safari、chrome 或 IE 中没有问题。
控制台显示:TypeError:togger 在此处未定义:
toggler.setStyle('color', '#666');
我想这很简单,但是对于这个新手,我不知道是怎么回事?有什么帮助吗?完整代码如下:
window.addEvent('domready', function() {
var myAccordion = new Accordion($('accordion'), 'h1.toggler', 'div.element', {
display: -1,
opacity: true,
alwaysHide: true,
onActive: function(toggler, element){
toggler.setStyle('color', '#df1a00');
//remove the toggler hover events to clear out its events when it was inactive
toggler.removeEvents('mouseenter');
toggler.removeEvents('mouseleave');
//then add your events again
toggler.addEvent('mouseenter',function()
{
//...
});
},
onBackground: function(toggler, element){
toggler.setStyle('color', '#666');
//remove the toggler hover events to clear out its events when it was active
toggler.removeEvents('mouseenter');
toggler.removeEvents('mouseleave');
//then add your events again
toggler.addEvent('mouseenter',function()
{this.setStyle('color', '#df1a00');
toggler.addEvent('mouseleave',function()
{this.setStyle('color', '#666');
});
});
}
});
var myAccordion2 = new Accordion($('accordion2'), 'h4.toggler', 'div.element2', { display: -1, opacity: true, alwaysHide: true, onActive: function(toggler, element){ 切换器。 setStyle('颜色', '#df1a00');
//remove the toggler hover events to clear out its events when it was inactive
toggler.removeEvents('mouseenter');
toggler.removeEvents('mouseleave');
//then add your events again
toggler.addEvent('mouseenter',function()
{
//...
});
},
onBackground: function(toggler, element){
toggler.setStyle('color', '#666');
//remove the toggler hover events to clear out its events when it was active
toggler.removeEvents('mouseenter');
toggler.removeEvents('mouseleave');
//then add your events again
toggler.addEvent('mouseenter',function()
{this.setStyle('color', '#df1a00');
toggler.addEvent('mouseleave',function()
{this.setStyle('color', '#666');
});
});
}
});
var myAccordion = new Accordion($('accordion3'), 'h5.toggler', 'div.element3', {
display: -1,
opacity: true,
alwaysHide: true,
onActive: function(toggler, element){
toggler.setStyle('color', '#df1a00');
//remove the toggler hover events to clear out its events when it was inactive
toggler.removeEvents('mouseenter');
toggler.removeEvents('mouseleave');
//then add your events again
toggler.addEvent('mouseenter',function()
{
//...
});
},
onBackground: function(toggler, element){
toggler.setStyle('color', '#666');
//remove the toggler hover events to clear out its events when it was active
toggler.removeEvents('mouseenter');
toggler.removeEvents('mouseleave');
//then add your events again
toggler.addEvent('mouseenter',function()
{this.setStyle('color', '#df1a00');
toggler.addEvent('mouseleave',function()
{this.setStyle('color', '#666');
});
});
}
});
});