这是我真正想要发生的事情:
页面加载时首先显示 div 当用户点击“向上箭头”时,箭头切换为“向下箭头”并隐藏 div。当用户单击“向下箭头”时,将显示 div。
但是,虽然我确实在页面加载时页面正确显示了 div,但是当用户单击“向上箭头”时,它会一直保持到用户再次单击它为止。
我有以下代码:
$(document).ready(function(){
$('.show_hide').click(function(){
$(".slidingDiv").slideToggle('slow',function() {
$('#arrow-down1').toggleClass('arrow-down1', $(this).is(':visible')); /* display the down arrow */
$('#arrow-down2').toggleClass('arrow-down2', $(this).is(':visible')); /* display the down arrow */
$('#arrow-up1').toggleClass('showhide', $(this).is(':visible')); /* hides the up arrow */
$('#arrow-up2').toggleClass('showhide', $(this).is(':visible')); /* hides the up arrow */
}); /* slidingDiv Toggle */
}); /* show_hide click function */
});
你可以在http://jsfiddle.net/jdYX6/7/看到这个
谢谢!