我正在使用 mootools 制作 Accordion 类型的内容部分。这是我正在使用的 HTML:
<div class="content-add">
<div class="item html 18" id="dditem_26">
<a id="ddlink_26"></a>
<a href="#" class="open ddheader"><strong>F. Tony Hosseini</strong></a>
<p>F. Tony Hosseini is the Founder and Chairman of the FTH Group of companies. He has over 30 years of experience in international business development, finance and private syndication work, developing and syndicating over $500 million dollars of industrial, commercial and residential projects around the world.</p>
<p>Before coming to the United States, Tony lived in Iran (Persia) where he served as the project Quality Control officer for National Construction Company, developing the natural gas line between Iran and the USSR. He was also a General Partner for Iran-America Insurance Company, a multi-line insurance operation in the southern region of Iran.</p>
</div>
<div class="item html 19" id="dditem_25">
<a id="ddlink_25"></a>
<a href="#" class="open ddheader"><strong>Robert J. O'Leary</strong></a>
<p>Robert J. (Bob) O'Leary is Vice Chairman of the FTH Group of companies. He also serves as a partner at Insignia Building, LLC, a leading construction company operating in high-end residential communities in the Carolinas. Bob brings with him over 30 years to the field of corporate public affairs, including communications, government affairs and brand management.</p>
<p>A native of Pennsylvania, Bob is a graduate of Penn State University, where he was named an Alumni Fellow. He serves on the Board of Visitors of the university's College of Communications, the college's campaign development committee, and regularly guest lectures and mentors students at the university. He resides in Greenville, South Carolina.</p>
</div>
</div>
目标是每当单击 a.open 时,使每个具有“open”类别的 下的所有内容滑出或滑入(切换)。这是我迄今为止拥有的 mootools JS:
$$('#content a.open').each(function(_link,i){
var _slide = _link.getNext('div.slide');
_slide.fx = new Fx.Slide(_slide).hide();
_link.addEvent('click', function(){
_link.toggleClass('open-slide');
_slide.getParent('.contentcol').getElements('.slide').each(function(slide) {
slide.slide('out');
});
_slide.fx.toggle();
});
slider 按预期“工作”,但在大多数情况下,幻灯片非常不稳定且“华丽”,因为在幻灯片期间,内容会随机消失并快速重新出现。有关此示例,请参阅 http://fthgroup.blueinkcms.com/about_us/leadership_team#然后单击其中一个名称。
你知道我可能做错了什么吗?
最佳答案
您发布的代码与您网站的标记不匹配。如果可能的话,您还应该升级到 mootools 1.2.4。
无论如何,解决此问题和 Fx.Slide 的性能问题(通过站点的源文件)可能比从头开始编写要花费更长的时间。
http://www.jsfiddle.net/P9zJa/ -> 这工作正常,重新分解以使用类,我希望它能给你一些想法。它对 html 的修改很少或没有改变,但请注意,我将 p
包装到 div.content
关于javascript - 我的 mootools 幻灯片代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2226550/