0
我有以下腳本來顯示/隱藏某些文本。我想讓切換按鈕成爲點擊時改變的圖像。 (例如,當崩潰時爲「+標題1」,當擴展時爲「 - 標題1」)是否有辦法實現這一點?mootools在按鈕上用css效果切換div
window.addEvent('domready', function(){
$$('.moreInfoWrapper').each(function(item){
var thisSlider = new Fx.Slide(item.getElement('.moreInfo'), { duration: 500 });
thisSlider.hide();
item.getElement('.divToggle').addEvent('click', function(){ thisSlider.toggle(); });
});
});
HTML:
<div class='moreInfoWrapper'>
<div class='divToggle'>
<h3>Title 1</h3>
</div>
<div class='moreInfo'>
<h3>More Info About Item 1</h3>
<p>Here is some content.</p>
<p>More Content</p>
<p>End of Content</p>
</div>
</div>
<div class='moreInfoWrapper'>
<div class='divToggle'>
<h3>Title 2</h3>
</div>
<div class='moreInfo'>
<h3>More Info About Item 2</h3>
<p>Here is some content.</p>
<p>More Content</p>
<p>End of Content</p>
</div>
</div>