![]() |
Web Development »
HTML / CSS »
General
Beginner
License: The Code Project Open License (CPOL)
Simple JQuery Tabs TemplateBy muhsin meydanA simple jquery tab as template that addresses few issues with JavaScript tabs |
C# (C#2.0), Javascript, CSS, HTML, XHTML, Windows, Linux, ASP, ASP.NET, WebForms, Ajax, Dev, Design
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
I was wondering how to make a simple tab and I found many different solutions for that. I tried a few of them, but I noticed a few issues with the ones I tried such as:
My JQuery Tabs Template addresses all the issues listed above. My development was in ASP.NET C#, but I have used simple HTML, CSS and a JQuery file for this example.
It would be worth looking at the JQuery official website for other templates and learning JQuery. However for this article, all you have to know is understand a bit of HTML. If you know a bit of CSS, that is good and you can change the coloring of the content. If you know JQuery, that is even better. That is it :).
Using the code is easy. In the sample I give you, I already use 5 tabs. You can change it as you like. So you can use any HTML editor of your choice for modifying the index.htm which holds the tabs and contents for each.
In the index.html, I have links to:
All the tab links are in the list format and for each list element, no anchors or links to anywhere are needed. This is the sample link: all you need is to add a new link in the list like this and change the step text.
This is how it looks:
In order to display content for the link we created, we need to have a tab content so our script will display it when the step1 link is clicked.
All we have to do is copy and paste the content tag in the HTML:
<div class="tabcontent"> I am going to be displayed when step 1 is clicked </div>
Note: The important thing here is the order of the tab contents and tab links. All the tabs are mapped to its content by the order of the "tabcontent"s. So first link "Step1" is mapped to first "div class='tabcontent' element in the "'div class="tabscontent_container'". Maintain the order when you add new tabs and contents. You don't have to add/modify any script.
tabscontent. All you have to do is copy the "div id='tabs_nav_wrapper'" around. DisplayTabContent() function. Change the line ending ".slideDown('slow');" to the animation type you want, e.g., ".slideUp();". This is JQuery animation. If you want to learn more about the types, go to the JQuery official site. Folks, I need your comments so I can improve this. If you find this useful, please email the link to your friends.
This is the first version of the simple JQuery Tabs Template.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 5 Aug 2009 Editor: Deeksha Shenoy |
Copyright 2009 by muhsin meydan Everything else Copyright © CodeProject, 1999-2010 Web21 | Advertise on the Code Project |