这是今天查资料写的,感觉挺繁琐的,大概有更简洁的方法吧,回头知道再整理吧。
效果图:随着鼠标点击左侧的三角形来回切换
html:
<a href="javascript:void(0)" class="fold"><img class="fold-icon" src="img/fold.png" alt="收起" /></a>
css:
.fold{
float: left;
margin-top: 4px;
width: 20px;
height: 20px;
}
js:
$('.fold').click(function(){
if($(this).children('.fold-icon').attr('src')=='img/fold.png'){
$(this).children('.fold-icon').attr('src','img/unfold.png');
}else{
$(this).children('.fold-icon').attr('src','img/fold.png');
}
$(this).nextAll('table:first').toggle(); //这个是随着三角的切换表单展开or收起切换
});