依妳要的效果,做了壹個簡單的例子,希望對妳有所幫助,本例效果:點擊左側?divleft?裏的鏈接?a?,右邊?divright?顯示不同的內容,代碼如下:
Xhtml?Code:
<div?id="divleft"><a?href="#">鏈接壹</a> 左側的鏈接
<a?href="#">鏈接二</a>
</div> <div?id="divright"><div>內容壹</div> 右側出現的內容
<div>內容二</div>
</div>jQuery?Code:
$('#divright?div').hide();
$('#divleft?a').each(function(i){
$(this).click((function(k){
return?function(){
var?int?=?k;
$('#divright?div').hide();
$('#divright').find('div').eq(int).show();
}
})(i));
});
Css?Code:
#divleft{?background:#ddd;?float:left;?height:100px;?padding:10px;?width:80px;}
#divleft?a{?color:#000;?display:block;}
#divright{?background:#eee;?float:left;?height:100px;?padding:10px;?width:300px;}
附效果圖壹張: