Site News |
---|
Warning: This wiki contains spoilers. Read at your own risk! Social media: If you would like, please join our Discord server, and/or follow us on X (Twitter) or Tumblr! |
MediaWiki:Tabs.js: Difference between revisions
From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.
mNo edit summary |
m (http://zeldawiki.org/index.php?title=MediaWiki:Tabs.js&direction=prev&oldid=309918) |
||
Line 1: | Line 1: | ||
/* | /* | ||
Simple but flexible javascript tabs | Simple but flexible javascript tabs | ||
v0.3 | |||
Author: Abdullah A. Abduldayem | Author: Abdullah A. Abduldayem | ||
Contact: http://www.zeldawiki.org/User:Abdullah | Contact: http://www.zeldawiki.org/User:Abdullah | ||
Line 6: | Line 7: | ||
*/ | */ | ||
function | $(document).ready(function(){ | ||
// When a tab is clicked | |||
$(".tab").click(function () { | |||
var $siblings = $(this).parent()children(); | |||
var $alltabs = $(this).closest(".tabcontainer"); | |||
var $content = $alltabs.parent().children(".tabcontents"); | |||
// switch all tabs off | |||
$siblings.removeClass("active"); | |||
// switch this tab on | |||
$(this).addClass("active"); | |||
// hide all content | |||
$content.children(".content").css("display","none"); | |||
// show content corresponding to the tab | |||
var index = $siblings.index(this); | |||
$content.children().eq(index).css("display","block"); | |||
}); | |||
}); | |||
} | |||
Revision as of 16:47, 3 May 2014
/*
Simple but flexible javascript tabs
v0.3
Author: Abdullah A. Abduldayem
Contact: http://www.zeldawiki.org/User:Abdullah
See http://www.zeldawiki.org/MediaWiki_talk:Tabs.js for examples and documentation
*/
$(document).ready(function(){
// When a tab is clicked
$(".tab").click(function () {
var $siblings = $(this).parent()children();
var $alltabs = $(this).closest(".tabcontainer");
var $content = $alltabs.parent().children(".tabcontents");
// switch all tabs off
$siblings.removeClass("active");
// switch this tab on
$(this).addClass("active");
// hide all content
$content.children(".content").css("display","none");
// show content corresponding to the tab
var index = $siblings.index(this);
$content.children().eq(index).css("display","block");
});
});