Javascript 单击选项卡后在确切的ID上滚动
我有以下选项卡代码,它是定制的:Javascript 单击选项卡后在确切的ID上滚动,javascript,tabs,Javascript,Tabs,我有以下选项卡代码,它是定制的: $(document).on('click', '#tabs li a', function () { var inst=$(this); window.location.hash = inst.attr('href'); $('#tabs li').each(function() { $(this).removeClass('active'); }) $('#tabs .tab').each(fun
$(document).on('click', '#tabs li a', function () {
var inst=$(this);
window.location.hash = inst.attr('href');
$('#tabs li').each(function() {
$(this).removeClass('active');
})
$('#tabs .tab').each(function() {
$(this).removeClass('activetabs');
})
inst.parent().addClass('active');
$(inst.attr('href')).addClass('activetabs');
return false;
})
var aloved_hashes = [];
if ($('#tabs ul li a').html() != undefined) {
$('#tabs ul li a').each (function() {
aloved_hashes.push($(this).attr('href'));
})
}
if (window.location.hash != '') {
var hash = window.location.hash;
if ($.inArray(hash, aloved_hashes) == -1) {
window.location.hash = '';
}
$('#tabs li').each(function() {
$(this).removeClass('active');
})
$('#tabs .tab').each(function() {
$(this).removeClass('activetabs');
})
$('a[href="'+hash+'"]').parent().addClass('active')
$(hash).addClass('activetabs');
}
不幸的是,google chrome开始变得凌乱,当我按下一个标签时,它总是滚动到ID,什么不应该做,有什么解决方案吗?我只是不想从中看到确切的ID。嗯,为什么不;难道你不让浏览器跟随链接吗?你用视窗,位置,散列…嗯,你有什么建议吗?删除部分代码?