Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($){
- $.fn.createTabs = function(){
- var container = $(this);
- container.find('.tab-content').hide();
- var tab_nr = 0;
- if (window.location.hash.indexOf('#tab') == 0) {
- var hash = window.location.hash.substr(1);
- if (typeof hash == 'number') {
- var tmp = parseInt(window.location.hash.substr(1));
- if (tmp > 0 && tmp < container.find('.tab-content').size()) {
- tab_nr = tmp - 1;
- }
- } else {
- var tab_name = container.find('#' + hash + '.tab-content');
- if (tab_name.size() && tab_name.not(':visible')) {
- tab_nr = tab_name.index();
- }
- }
- }
- container.find("ul.tabs li").eq(tab_nr).addClass("active").show();
- container.find(".tab-content").eq(tab_nr).show();
- container.find("ul.tabs li").click(function() {
- container.find("ul.tabs li").removeClass("active");
- $(this).addClass("active");
- container.find(".tab-content").hide();
- var activeTab = $(this).find("a").attr("href");
- $(activeTab).fadeIn();
- return false;
- });
- };
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement