两则代码都很简单,这里就不多废话了,直接上代码
代码1,
function ntabs(thisObj,Num) {if(thisObj.className == "active")return; var tabObj = thisObj.parentNode.id; var tabList = document.getElementById(tabObj).getElementsByTagName("li"); for(i=0; i <tabList.length; i++) {if (i == Num) {thisObj.className = "active"; document.getElementById(tabObj+"_cont"+i).style.display = "block"; } else{ tabList[i].className = "normal"; document.getElementById(tabObj+"_cont"+i).style.display = "none"; } } }
代码2,
$(document).ready(function(){ var $tab_li = $('.tab ul li'); $tab_li.hover(function(){ $(this).addClass('selected').siblings().removeClass('selected'); var index = $tab_li.index(this); $('div.tab_box > div').eq(index).show().siblings().hide(); }); });
新闻热点
疑难解答