Home > Web Front-end > JS Tutorial > body text

jquery Tab common function_jquery

WBOY
Release: 2016-05-16 18:29:05
Original
1418 people have browsed it

核心代码:

复制代码 代码如下:

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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template