我正在使用mootools制作一个手风琴类型的内容部分。下面是我正在使用的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下的所有内容都有一个“打开”的类,无论何时点击它,都会滑出或滑入(切换)。以下是我到目前为止拥有的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();
});滑块“工作”如预期,除了大多数时间,幻灯片是非常起伏和“华而不实”,因为在幻灯片中,内容将随机消失,并迅速重新出现。有关这种情况的示例,请参见http://fthgroup.blueinkcms.com/about_us/leadership_team#并单击其中一个名称。
你知道我会做错什么吗?
发布于 2010-02-09 23:38:43
您发布的代码与您网站的标记不匹配。如果可能,您还应该升级到mootools 1.2.4。
无论如何,(通过您的站点的源文件)针对性能不佳的问题对其和Fx.Slide进行故障排除可能比从头开始编写要花费更长的时间。
http://www.jsfiddle.net/P9zJa/ ->这个工作很好,重构后使用了一个类,希望它能给你一些启发。只需很少或根本不修改html,它就会得到增强,但请注意,我将p打包成了一个div.content
https://stackoverflow.com/questions/2226550
复制相似问题