Navigation menu

MediaWiki:Gadget-Tabs.js

From Metroid Wiki
Revision as of 20:11, 31 January 2024 by Prod (talk | contribs) (remove section linking and update classes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$(document).ready(function(){
	// When a tab is clicked
	$(".tab").click(function () {
		var $siblings= $(this).parent().children();
		var $alltabs = $(this).closest(".tabheader");
		var $content = $alltabs.parent().children(".tabcontents");

		// switch all tabs off
		$siblings.removeClass("active");
		$content.children().removeClass("content--active");

		// switch this tab on
		$(this).addClass("active");
		var index = $siblings.index(this);
		$content.children().eq(index).addClass("content--active");
	});
});