// tab
$(function(){
? ? function tabSwitch(tab,tabbox,box){
? ? ? ? this.tab = tab;
? ? ? ? this.tabbox = tabbox;
? ? ? ? this.box = box;
? ? ? ? tabSwitch.prototype.switch = function(){
? ? ? ? ? ? $(tabbox).find(box +":first").show();? ? //為每個(gè)BOX的第一個(gè)元素顯示? ? ? ?
? ? ? ? ? ? $(tab).on("click",function(){ //給a標(biāo)簽添加事件
? ? ? ? ? ? ? ? var index=$(this).index();? //獲取當(dāng)前a標(biāo)簽的個(gè)數(shù)?
? ? ? ? ? ? ? ? $(this).parent().next().find(box).hide().eq(index).show(); //返回上一層,在下面查找css名為box隱藏,然后選中的顯示?
? ? ? ? ? ? ? ? $(this).addClass("active").siblings().removeClass("active"); //a標(biāo)簽顯示,同輩元素隱藏
? ? ? ? ? ? ? ? // 滾動(dòng)到底部
? ? ? ? ? ? ? ? var height = $(box).height();
? ? ? ? ? ? ? ? $(tabbox).scrollTop(height);? ? ?
? ? ? ? ? ? })
? ? ? ? }? ? ?
? ? }
? ? // 消息內(nèi)容切換
? ? var TAB = new tabSwitch('.message-tab span','.message-list','.message-box');
? ? TAB.switch();
})