87,990
社区成员
发帖
与我相关
我的任务
分享
<input id="bnt1" type="button" value="1" />
<input id="bnt2" type="button" value="2" />
<input id="bnt3" type="button" value="3" />
<input id="bnt4" type="button" value="4" />
<div id="tejia">
<div>111</div>
<div>222</div>
<div>333</div>
<div>444</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(function(){
for(var i=1;i<=4;i++){
$("#bnt"+i).bind('click',(function(n){
return function(){
$("#tejia>div").each(function(index){
if(index==(n-1)) $(this).css("display","block");
else $(this).css("display","none");
})
}
})(i));
}
})
</script>