Created
February 25, 2017 11:15
-
-
Save nollac/caf60bbad95ca0eb5a66982dce32803f to your computer and use it in GitHub Desktop.
jq tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
jQuery.fn.lightTabs = function(options){ | |
var createTabs = function(){ | |
tabs = this; | |
i = 0; | |
showPage = function(i){ | |
$(tabs).children("div").children("div").hide(); | |
$(tabs).children("div").children("div").eq(i).show(); | |
$(tabs).children("ul").children("li").removeClass("active"); | |
$(tabs).children("ul").children("li").eq(i).addClass("active"); | |
} | |
showPage(0); | |
$(tabs).children("ul").children("li").each(function(index, element){ | |
$(element).attr("data-page", i); | |
i++; | |
}); | |
$(tabs).children("ul").children("li").click(function(){ | |
showPage(parseInt($(this).attr("data-page"))); | |
}); | |
}; | |
return this.each(createTabs); | |
}; | |
})(jQuery); | |
$(document).ready(function(){ | |
$(".offer_tabs").lightTabs(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment