Home  >  Article  >  Web Front-end  >  jquery Tab common function_jquery

jquery Tab common function_jquery

WBOY
WBOYOriginal
2016-05-16 18:29:051422browse

核心代码:

复制代码 代码如下:

function cur(ele){
$(ele).addClass("cur").siblings().removeClass("cur");
}
function tab(id_tab,tag_tab,id_con,tag_con,act){
$(id_tab).find(tag_tab).eq(0).addClass("cur");
$(id_con).find(tag_con).eq(0).show().siblings(tag_con).hide();
if(!act){ act="click"};
if(act=="click"){
$(id_tab).find(tag_tab).each(function(i){
$(id_tab).find(tag_tab).eq(i).click(function(){
cur(this);
$(id_con).find(tag_con).eq(i).show().siblings(tag_con).hide();
})
})
}
if(act=="mouseover"){
$(id_tab).find(tag_tab).each(function(i){
$(id_tab).find(tag_tab).eq(i).mouseover(function(){
cur(this);
$(id_con).find(tag_con).eq(i).show().siblings(tag_con).hide();
})
})
}
}
$(document).ready(function(){
tab("#tri","li","#game_con","div","click");
});

演示代码:运行后,需要刷新下,才能加载jquery
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn