當前位置:編程學習大全網 - 網站源碼 - 我用DIV做的盒子,怎麽才能在左邊點擊連接然後本頁面右邊顯示內容,不用框架。用ajax和js怎麽用。求詳細例

我用DIV做的盒子,怎麽才能在左邊點擊連接然後本頁面右邊顯示內容,不用框架。用ajax和js怎麽用。求詳細例

依妳要的效果,做了壹個簡單的例子,希望對妳有所幫助,本例效果:點擊左側?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;}

附效果圖壹張:

  • 上一篇:能不能mcall _
  • 下一篇:gtx1080ti如何看顯卡體質?
  • copyright 2024編程學習大全網