JS tab切换事件

时间:2023-12-09 16:56:07
$('ul.main-tab>li').on('mousedown', data, function() {
var $this = $(this), $box = $('.main-tab-content'), i = $this.index();
if ($this.hasClass('on')) { return false; }
switch (i) {
case 1:
window.radarUpdater = self.setInterval(function(){updateRadarTab(data)}, 3000);
break;
case 2:
clearInterval(window.radarUpdater);
updateoptional();
break;
case 3:
clearInterval(window.radarUpdater);
updateNoticeTab();
break;
default:
break;
}
$this.siblings().removeClass('on');
$this.addClass('on');
$box.removeClass('block').css('display', 'none');
$box.eq(i).addClass('block').css('display', 'block');
});