Animated tabbed content with jQuery

186

A lot of websites on the Internet have tabbed content now a days. The problem I find with most of them is that most of the time they can be quite dull. For my new looks I created a container which has the ability to switch content through tabs, but with an animation. This tutorial will show you how to create your own tabbed content step by step.

tabbedpost

Tweet

Download
Tabbed Content zip-archive
Example
View the Tabbed Content in action!

In this tutorial I am going to show you some web development techniques that can be used in your next projects. This will cover some CSS, HTML and jQuery tricks.

The sources of this tutorial are downloadable here: http://www.gayadesign.com/scripts/tabbed/tabbedContent.zip

Example of the outcome is found here: http://www.gayadesign.com/scripts/tabbed/

First thing we need is some basic HTML layout to fit what we are going to make.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>Tabbed content</title>
		<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
		<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js'></script>
		<link href='css/tabbedContent.css' rel='stylesheet' type='text/css' />
		<script src="js/tabbedContent.js" type="text/javascript"></script>
	</head>
	<body>
	</body>
</html>

I already included jQuery and other files in the head section. We’ll be making these files step by step in the next few minutes.

Next thing we need to do is create the structure of the document. What we need is a container with the tabs and a container which the content will that switch if we change tabs.
As a nice feature to enhance this all we’ll use a tab background that will move to the choice the user makes. While this tab moves, the content will also change to the selected tab.

For this we need a container containing the tabs and the background, a container containing the content and container that prevents the content to be shown prematurely.

Take a look at the following code:

<div class='tabbed_content'>
	<div class='tabs'>
		<div class='moving_bg'>
			 
		</div>
		<span class='tab_item'>
			Tab one
		</span>
		<span class='tab_item'>
			Tab two
		</span>
		<span class='tab_item'>
			Tab three
		</span>
		<span class='tab_item'>
			Tab four
		</span>
	</div>
	<div class='slide_content'>
		<div class='tabslider'>
			<!-- content goes here -->
		</div>
	</div>
</div>

It’s time to do a little styling to the tabs section and the overall container. Note that in the next part I am going to use an image which is included in the source archive. This will enhance the looks of the tabbed container.

This following CSS will make the tabs appear as tabs:

.tabbed_content {
	background-color: #000000;
	width: 620px;
}
.tabs {
	height: 62px;
	position: relative;
}
.tabs .moving_bg {
	background-color:#7F822A;
	background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/arrow_down_green.gif);
	background-position: bottom left;
	background-repeat: no-repeat;
	left: 0;
	padding: 15px;
	padding-bottom: 29px;
	position: absolute;
	width: 125px;
	z-index: 190;
}
.tabs .tab_item {
	display: block;
	float: left;
	padding: 15px;
	width: 125px;
	color: #ffffff;
	text-align: center;
	z-index: 200;
	position: relative;
	cursor: pointer;
}

Note that the tab container has a position of relative to make the moving background position to it. Now we can easily move the moving background using the left property.

In the next part we are going to add the first few lines of Javascript to the tabbedContent.js file to create a mouseover effect on the tab items.

Use this code as a skeleton:

var TabbedContent = {
	init: function() {	
	},
	slideContent: function(obj) {
	}
}
$(document).ready(function() {
	TabbedContent.init();
});

This code is will execute the init function once the page is loaded.

Now we need to make is so that the moving background moves to the tab item which is hovered on. Implement the following code:

$(".tab_item").mouseover(function() {
	var background = $(this).parent().find(".moving_bg");
	$(background).stop().animate({
		left: $(this).position()['left']
	}, {
		duration: 300
	});
	TabbedContent.slideContent($(this));
});

This will make all the items with the class tab_item behave as if it was a tab. It also moves the moving background to the right position, matching the left property with that of the tab.

TabbedContent.slideContent($(this)); will make the content switch in a few steps. We’ll get to that.

Next up is creating the content and it’s CSS. The content goes in the place we put .

<ul>
	<li>
		This matches the first tab
	</li>
</ul>
<ul>
	<li>
		This matches the second tab
	</li>
</ul>
<ul>
	<li>
		This matches the third tab
	</li>
</ul>
<ul>
	<li>
		This matches the fourth tab
	</li>
</ul>

And the matching CSS:

.tabbed_content .slide_content {
	overflow: hidden;
	background-color: #000000;
	padding: 20px 0 20px 20px;
	position: relative;
	width: 600px;
}
.tabslider {
	width: 5000px;
}
.tabslider ul {
	float: left;
	width: 560px;
	margin: 0px;
	padding: 0px;
	margin-right: 40px;
}
.tabslider ul a {
	color: #ffffff;
	text-decoration: none;
}
.tabslider ul a:hover {
	color: #aaaaaa;
}
.tabslider ul li {
	padding-bottom: 7px;
}

Note that the content has two containers. One is for the overall wrapping and the other for making the content move as we hover over the items.

The top container has an overflow of hidden, which makes any content that goes out of it’s limits hidden. The container below that will hold the content that will be hidden.

Now we are going to make the content scroll to the right position as we did with the tabs.

It’s time to fill up the slideContent function:

var margin = $(obj).parent().parent().find(".slide_content").width();
margin = margin * ($(obj).prevAll().size() - 1);
margin = margin * -1;
$(obj).parent().parent().find(".tabslider").stop().animate({
	marginLeft: margin + "px"
}, {
	duration: 300
});

The margin needed for the slider to move is calculated in this function. It has been made so that you can change the widths of several containers in the result, it will scroll to the right position automatically.

Take another looks at the source for references.

Good luck with making your own tabbed content in your future projects.

Articles like this one

Articles like this one

If you liked this article you can add this post to:


 

133 Comments

  1. evan said: April 26, 2025 at 8:30 pm | Permalink

    Awesome man! I would make the area which determines the slider to move to be the <a> rather than the <div>. If content is too far over to the left then mouse could hit the next sections causing the content to change unwarranted.

    Evan


  2. Gaya said: April 26, 2025 at 8:49 pm | Permalink

    Thanks for the comment Evan!
    You have a point there. It would increase the usability of the whole concept. Thanks for sharing your thoughts.


  3. Mike said: April 26, 2025 at 9:38 pm | Permalink

    Very cool! Though, what happens if the user has JavaScript turned off?


  4. Gaya said: April 26, 2025 at 9:44 pm | Permalink

    @Mike: I have no idea… I guess they wont switch 😛


  5. Tyler Jefford said: April 26, 2025 at 11:20 pm | Permalink

    Hey! Very cool effect you have made. I really like content sliders.

    Also going along with @mike If the JavaScript has been disabled then none of the tabs work.

    Have a great day!

    -tjefford


  6. Gaya said: April 27, 2025 at 12:12 am | Permalink

    Thanks for the comment Tyler. Maybe the tabs should be clickable if Javascript is disabled.


  7. neki chan said: April 27, 2025 at 11:03 am | Permalink

    coolllll…
    wanna try it
    thanks 😀


  8. Farrhad A said: April 27, 2025 at 8:12 pm | Permalink

    Another uber kewl tutorial on GD 🙂


  9. Peter Witham said: April 27, 2025 at 9:14 pm | Permalink

    Great example and well executed, thanks for sharing.


  10. Gaya said: April 28, 2025 at 8:57 am | Permalink

    @Neki, Farrhad and Peter:

    Thanks for the comments and good luck with trying it out 😀


  11. Drew Douglass said: April 28, 2025 at 9:11 am | Permalink

    The effect is super slick and pretty original, different from most tabs I have seen. Keep up this kind of material Gaya, I really enjoy it!

    As for the flaw with JavaScript being disabled, you could try setting the overflow to hidden with JS and set the default CSS to scroll so the user could scroll through the content. Haven’t tested this, just a quick ide from a glance at the demo and code.

    Great work!


  12. Gaya said: April 28, 2025 at 9:16 am | Permalink

    Hi Drew!

    Thanks for checking out the article and commenting! Much appreciated 😀

    As for the fix to the problem; it is a solution worth trying. Maybe even make the tabs scrollable with them. I sometimes wonder how many people don’t use Javascript these days.


  13. Hiro said: May 4, 2025 at 5:28 pm | Permalink

    Sweet tutorial 🙂 Appreciate all the details.


  14. Gaya said: May 4, 2025 at 6:24 pm | Permalink

    No problem Hiro! Stick around for more 😉


  15. Ahmet said: May 7, 2025 at 11:37 am | Permalink

    Thanks for this work. This is great! Good work!


  16. Gaya said: May 8, 2025 at 11:01 am | Permalink

    Thank Ahmet! Have fun with it!


  17. Liviu said: May 12, 2025 at 10:06 pm | Permalink

    Thanks for sharing this script, the idea is great. How about converting it into a jQuery plugin?


  18. Gaya said: May 13, 2025 at 8:35 am | Permalink

    I might make a plugin in the near future 🙂 stay tuned!


  19. Raphael said: May 31, 2025 at 5:41 pm | Permalink

    How do i make it animate when the click of the mouse is done instead of the mouseover function?


  20. Raphael said: May 31, 2025 at 6:13 pm | Permalink

    I´ve just solved this problem I have aked for help just by changing mouseover in the js code to mousedown and it worked perfectly


  21. Gaya said: May 31, 2025 at 8:22 pm | Permalink

    @raphael:
    Good! jQuery is really that easy. Glad you liked it 🙂


  22. dtr said: June 4, 2025 at 9:17 am | Permalink

    Great stuff mate, nice to see someone this creative. Everything work like a charm, but in firefox there’s a problem when you insert the . Keep the great job.


  23. dtr said: June 4, 2025 at 9:23 am | Permalink

    sorry the image tag


  24. Gaya said: June 5, 2025 at 5:09 pm | Permalink

    Hi dtr,

    Are you inserting the image tag inside a ul? that way it should work.
    Good luck 🙂


  25. dlv said: June 16, 2025 at 4:00 pm | Permalink

    thanks Gaya, it’s a great menu, it’s what i was looking for… i’m using it in my website and looks great

    thanks for share it!!

    PD: a have little question, when you use the menu and click on a tab link, when page reload, the slide button “.moving_bg” is allways in the first position not showing the new open page.
    There is a way to remember the active page, so “.moving_bg” position match with the open page/category?

    thanks in advance!

    adeux, from argentina


  26. W.Dohmen said: June 19, 2025 at 5:44 pm | Permalink

    Looks really nice, just the kind of thing I was looking for thnx for the tut (y)


  27. Vector Man said: July 31, 2025 at 6:02 am | Permalink

    Hi. I think its not comfortable when content links located far away from his title.


  28. Ravikumar V. said: September 16, 2025 at 8:23 am | Permalink

    really nice creative website design.. 🙂


  29. Siddharth said: September 24, 2025 at 7:34 am | Permalink

    Thanks for your gr8 work. it’s really gr8;

    i have one question: can we use iframe under any tab? i tried but its not showing correctly, please check and update us with ur gr8 work 🙂 thanks!

    SiD


  30. Gaya said: September 24, 2025 at 4:49 pm | Permalink

    Have you tried putting the iframe inside a list?
    The script was made to move around ul tags. So try to do:
    ul > li > iframe
    good luck!


  31. moabi said: October 19, 2025 at 9:21 am | Permalink

    a very nice slider, simple, efficient, and no click !!!
    check your slider here
    much thanks from him

    http://www.yifan-cirque.com/bio(graphie).php


  32. khits said: October 29, 2024 at 3:41 am | Permalink

    Hi, i’m trying this slider in my website but it’s not working… I followed every step of the instructions but it seems i’m missing something…

    check: http://www.wordofhope.ph/tabbed


  33. khits said: October 29, 2024 at 3:43 am | Permalink

    Hi, i’m trying to put this slider in my website but it’s not working… I followed every step of the instructions but it seems i’m missing something…Will you please tell me what did I missed.

    check: http://www.wordofhope.ph/tabbed.html


  34. Gaya said: October 29, 2024 at 9:12 am | Permalink

    @moabi: Looks cool dude! Glad you liked it 🙂

    @khits: I see you are missing the jQuery file + the AnimatedTabs file gives a 404. Fix these first.


  35. oh!curiouser said: October 30, 2024 at 12:22 am | Permalink

    Thanks! I like it very, very much!!!


  36. ukwebguy said: November 26, 2024 at 2:39 pm | Permalink

    This is good stuff! Thank you for sharing. I have just one small problem – it works great with 4 tabs but when I try and extend it to 5 or 6 tabs the content stays withing the original 4 tab width no matter what I do to the content width. Would it be possible to have a few instructions on extending this to more than 4 tabs for those of us who are “CSS challenged”?


  37. Chuck Snyder said: December 1, 2024 at 12:46 am | Permalink

    Wonderful little tool. Wow’d the boss.

    I was having a problem displaying 12 tabs. After adding the 5th tab (I was testing as i added each one), they started to double up.

    It took a few minutes to realize what was happening, the .tabslider in the css file was set to 5000px. Adding up the width of the tabs comes up to quite a bit more than 5000px, so upped it to 10000px and now it works just fine.

    Thanks for the good work.


  38. Chuck Snyder said: December 1, 2024 at 6:38 pm | Permalink

    One problem I’m having, I have a couple of GridViews in seperate tabs, and one of the grids is larger than the other.

    How would I make one tab display wider than the others??


  39. Dre said: December 17, 2024 at 11:50 pm | Permalink

    I am interested in using this with the tabs lined up to the left of the content slider above each other. More like buttons than tabs.

    Any ideas?


  40. Nasiba Ansari said: February 17, 2025 at 4:39 pm | Permalink

    Really nice script. I am using in my site.


  41. Kevin said: March 18, 2025 at 2:50 am | Permalink

    hi Gaya, no matter how much I try to put your animated tab into my blog, i can’t do it. Could you please look at my theme for me, and tell me what I did wrong. I am willing to donate to you if you can make your animated script work into my theme.


  42. sajan kota said: March 25, 2025 at 2:46 pm | Permalink

    Looks kool , execellent use of jquery.


  43. diptekosede said: April 2, 2025 at 5:26 pm | Permalink

    Great example and well executed, thanks for sharing.


  44. Michael said: April 19, 2025 at 11:08 am | Permalink

    Hi, How can you make the content to slide verticaly instead of horizontaly? Thanks


  45. ashish said: April 27, 2025 at 2:43 pm | Permalink

    gr8 work….the sliding effect is running but the content is not working when i change the tab. 🙁


  46. Cingene said: May 10, 2025 at 3:55 am | Permalink

    I found a Bug.
    When i include the newest jQuery 1.4.2 from Google Apis, then in Opera 10.53 your Script are Problems.
    @gaya: Please test it self with jQuery 1.4.2


  47. Criss said: May 18, 2025 at 9:27 pm | Permalink

    comment 37: setting 10000px doesn’t work for me
    comment 45: I got the same problem, content doesn’t appear at all

    Any ideas how to solve the above?


  48. piterPL said: May 19, 2025 at 2:37 pm | Permalink

    It doesn’t work in IE8 ;/


  49. Criss said: May 27, 2025 at 7:10 pm | Permalink

    I would like to have a link inside a tab to go to another tab, keeping the sliding effect. What code should I add ?


  50. Website Design said: June 12, 2025 at 6:53 am | Permalink

    Really very excellent just imagine many many thanks for posting this.


  51. Scrapsforever said: September 10, 2025 at 12:11 pm | Permalink

    Amazing jquery tutorials, its excellent
    thanks


  52. Felix said: October 12, 2025 at 6:46 pm | Permalink

    Muy bueno.. gracias me sera util


  53. Michael Mallett said: October 12, 2025 at 8:59 pm | Permalink

    Is there a way of seperating the tabs from the content switcher in the jquery?

    Having them one above the other really restricts the design, even if it does make for very lightweight coding.


  54. Sol said: November 6, 2024 at 5:24 am | Permalink

    Hi

    I am using a modified version of this excellent script:

    I have it set up to display an individual background image in the main UL content area, along with text sitting on top of the images (for seo).

    Upon hover over the title tab, the new content slides into view – but in IE7 / 8 it only shows the first content tab.

    This works perfectly in all browsers except IE and I am convinced it is the javascript that is not being correctly read by IE. As you can see, I’ve added the .tabslider arguments – which are correctly read by all browsers except IE.

    Being a total javascript newbie – I’m hoping someone here could help me out.

    Here’s the script

    //tab effects

    var TabbedContent = {
    init: function() {
    $(".tab_item").mouseover(function() {

    var background = $(this).parent().find(".moving_bg");

    $(background).stop().animate({
    left: $(this).position()['left']
    }, {
    duration: 300
    });

    TabbedContent.slideContent($(this));

    });
    },

    slideContent: function(obj) {

    var margin = $(obj).parent().parent().find(".slide_content").width();
    margin = margin * ($(obj).prevAll().size() - 1);
    margin = margin * -1;

    $(obj).parent().parent().find(".tabslider1, .tabslider2, .tabslider3, .tabslider4, .tabslider5, .tabslider6").stop().animate({
    marginLeft: margin + "px"
    }, {
    duration: 300
    });
    }
    }

    $(document).ready(function() {
    TabbedContent.init();
    });

    Here’s the CSS

    .tabbed_content {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/slide-back1.png);
    width: 975px;
    height: 400px;
    }

    .tabs {
    height: 62px;
    position: relative;
    }

    .tabs .moving_bg {
    padding: 15px;
    background-color:#ff9900;
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/arrow_down_green.gif);
    position: absolute;
    width: 125px;
    z-index: 190;
    left: 0;
    padding-bottom: 29px;
    background-position: bottom left;
    background-repeat: no-repeat;
    }

    .tabs .tab_item {
    display: block;
    float: left;
    padding: 15px;
    width: 125px;
    color: #666;
    text-align: center;
    z-index: 200;
    position: relative;
    cursor: pointer;
    }

    .tabbed_content .slide_content {
    overflow: hidden;
    background-color: #eee;
    padding: 20px 0 20px 0px;
    margin-left:20px;
    position: relative;
    width: 900px;
    }

    .tabslider1, .tabslider2, .tabslider3, .tabslider4, .tabslider5, .tabslider6 {
    width: 7000px;

    }

    .tabslider1 ul, .tabslider2 ul, .tabslider3 ul, .tabslider4 ul, .tabslider5 ul, .tabslider6 ul {
    float: left;
    width: 900px;
    height:200px;
    margin: 0px;
    padding: 100px 0 0 0;
    list-style:none;
    }

    .tabslider1 ul {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/1.jpg);

    }

    .tabslider2 ul {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/2.jpg);

    }

    .tabslider3 ul {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/3.jpg);

    }

    .tabslider4 ul {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/4.jpg);

    }

    .tabslider5 ul {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/5.jpg);

    }

    .tabslider6 ul {
    background-image:url(https://gayadesign.com/wp-content/themes/3g70upa9virgr09b178c8455240/files/images/6.jpg);

    }

    .tabslider1 ul a, .tabslider2 ul a, .tabslider3 ul a, .tabslider4 ul a, .tabslider5 ul a, .tabslider6 ul a {
    color: #666;
    text-decoration: none;
    }

    .tabslider1 ul a:hover, .tabslider2 ul a:hover, .tabslider3 ul a:hover, .tabslider4 ul a:hover, .tabslider5 ul a:hover, .tabslider6 ul a:hover {
    color: #aaaaaa;
    }

    .tabslider1 ul li, .tabslider2 ul li, .tabslider3 ul li, .tabslider4 ul li, .tabslider5 ul li, .tabslider6 ul li {
    padding-bottom: 7px;
    padding-left:40px;

    }

    And here’s the page html:

     

    Cars

    Bikes

    Trucks

    People

    Animals

    Flags


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


    text text text


  55. The 16i Team said: November 8, 2024 at 1:28 pm | Permalink

    Hi,
    This is a very neat bit of code. We are currently using it as a type of “Supermarket Shelf” system on our brand new website.

    http://www.16i.co.uk/

    Are there any plans to update it so that if you are not mousing over the “nav” that the content scrolls automatically?

    Dave@16i


  56. Sol said: November 12, 2024 at 2:39 am | Permalink

    Hi 16i thanks for sharing that – your design helped me understand more about the relationship between this code and images.

    … nice site too….


  57. Alex Coady said: November 19, 2024 at 5:54 pm | Permalink

    I’m very impressed with this tutorial, it’s exactly what I was looking for. However, and this might be really simple, I’m struggling to set different colors for the tab text that isn’t currently selected. (i.e. The name of the tabs that aren’t currently selected).

    Can you think of a simple way to do this?

    Great work!

    alex


  58. Andreas Ash said: November 19, 2024 at 6:43 pm | Permalink

    Please help!

    Have a look at http://www.dj-ash.co.uk with CHROME browser…

    The text if offset and I don’t know how to fix it!

    Works fine with FF and IE…

    please email me at info@dj-ash.co.uk if you can be kind enough

    thanks

    Andy


  59. Julien said: December 5, 2024 at 5:10 am | Permalink

    Thank you for this great script.
    Could you help me set it up in the following way:
    I would like to display some text by default that comes back whenever the mouse is not hovering above a tab.
    Any ideas?
    Thank you!!!


  60. Andreas Ash said: December 21, 2024 at 5:47 pm | Permalink

    The tabbed content script doesn’t work for me in Chrome. The contents are displaced.

    Please have a look at http://www.dj-ash.co.uk

    What am I doing wrong ?


  61. Maria said: January 19, 2025 at 6:34 pm | Permalink

    Great tutorial, This tabs are very very nice for one of my projects, thank you for your help, and congrantulations very nice work.


  62. Oli said: January 26, 2025 at 1:28 am | Permalink

    Is it possible to call the change tab section of the code from general javascript in the page – eg based on the an # url var
    any help would be appreciated.
    Oli


  63. รับทำเว็บไซต์ said: January 30, 2025 at 12:20 pm | Permalink

    Awesome …..! I bookmared it on Delicious and submitted

    on Digg. Hopefully it sends more people your way


  64. dorian said: February 4, 2025 at 11:10 am | Permalink

    Wonderful! thank you! this script is perfect! i was looking for a long time, and this one is what i needed! 😀

    Thanx


  65. Todd said: February 26, 2025 at 6:37 pm | Permalink

    First of all, thanks a lot for this! It’s amazingly nice, and I’m about to use it on a website I’m creating (it’s a simple website, the only animation is this tabbed view 😀 ).

    Now I read some people wanna know how to change the text color of the tab that’s been hovered on, and I noticed it doesn’t look good if it’s not animated.

    As I do not have a domain yet, I cannot show it, I would upload the source code but I’m afraid someone will steal the design or something.

    Feel free to mail me at todd.david9@gmail.com though!


  66. Abbas said: March 1, 2025 at 5:03 pm | Permalink

    Hiya,
    Great code, I am trying to select middle or right tab by default, can any one kindly help?
    Many thanks in advance.


  67. jaws said: March 7, 2025 at 1:57 pm | Permalink

    “change tab section of the code from general javascript in the page – eg based on the an # url var” << this is the most important feature to add or to explain.

    Any idea ?


  68. Rida57 said: March 13, 2025 at 9:53 pm | Permalink

    My version of it, please let me know what you think
    the render on Mozilla 3.6 is the best one


  69. ludo said: March 22, 2025 at 4:09 pm | Permalink

    Hey,
    great code… i’m trying to use it in my futur website, but i have a little problem…
    i’ve put images in tabbed content, and i want to use lightbox on them, but when i put the lightbox.js, tabbedcontent.js stop to work… how can i do? is it normal?

    thanks!

    ( i’m french so sorry for my language… 🙂


  70. Eyes Drinker said: April 6, 2025 at 5:35 pm | Permalink

    Very nice, Thank you for effort. Can i change event from mouseover to click?? as some time unintentionally mouse rolled over tab and is selected.


  71. prahalad said: April 19, 2025 at 8:42 am | Permalink

    height is defined, it takes default height for all the tabs content..
    IF first tab has more content, it is taking the same height for other tabs as well even if there is less content…how to assign height according to its content in indivudual tabs,…


  72. Nick said: April 25, 2025 at 9:39 pm | Permalink

    It is a nice tabbing system, with one huge ironic flaw; “Don’t press the TAB KEY from the last item (highest tabindex) on the current tab!”

    What happens is the browser (tested in FF, Chrome, IE and Safari) shifts the content, but only by the amount of space required to show the next item in the tabindex, which in my case is the first input box on the next tab. At that point, changing the tabslider left margin or the moving_bg left margin to correct values has no effect on restoring the screen. The browser, in effect, gets stuck between tabs until you issue a reload of the page.

    At first I thought I could compensate for this defect, since I created a routine to position the tabs to any initial tab on a page reload via a $_POST value. But no go. Once the browser gets stuck in between it’ll stay that way.

    Go ahead. Check it out with the demo. Repeatedly strike the tab key until it tries to bring the focus to a tabindex on another tab.

    I’ve tried a number of techniques involving onKeyPress, etc. but I believe this is beyond my expertise.

    In my case, I’m using the tabslider as an input wizard, so the ability to tab from one tab to the next is critical.

    It would be nice to have a fix for this problem. It’s otherwise a very handy routine.

    Thank for the slider!


  73. marcus said: May 6, 2025 at 2:47 pm | Permalink

    Hi, great tutorial! Is it possible to have the menu revert to its original position on mouseout?

    Thanks!


  74. Kary Ockerman said: May 19, 2025 at 11:07 am | Permalink

    Hey there! This is my 1st comment here so I just wanted to give a quick shout out and say I really enjoy reading your posts. Can you suggest any other blogs/websites/forums that go over the same topics? Many thanks!


  75. miguel said: May 31, 2025 at 2:46 am | Permalink

    hi !! it’s great… but….. only work with jquery 1.3 ? 🙁 not work with jquery 1.6 ? or 1.4 ? 🙁


  76. Trek said: June 20, 2025 at 6:20 pm | Permalink

    I was pleased to find you script but I am a novice and do not know how to associate each tab to individual content. Is the code you provide generic and needs to be customized?

    I spent time on the look and feel by changing CSS settings, but what do I put in the DIV tag to connect with each tab?

    Confused… ??


  77. Trek said: June 20, 2025 at 7:14 pm | Permalink

    OOPS… never mind… haa… it was right in front of me!!


  78. Samson said: July 3, 2025 at 5:35 pm | Permalink

    Fantastic, i really love this. but, what if i dont want d tab function to change on “hover state”, i want it to change when u “click” on the tab!!! what am i to alter in d jQuary?


  79. Pbnj4640 said: July 25, 2025 at 2:56 pm | Permalink

    this is an awesome slider, thank you! im trying to modify it to run vertically and ive edited all the css and everything, the JS i cannot for the life of me figure out… the content is fine right to left, but i wanna make the tabs themselves run top to bottom and i have no idea what im doing?


  80. hitomi gilliam floral designer said: August 8, 2025 at 10:52 pm | Permalink

    Great blog man, had a lot of great reads! just like to see you update your site now, that would be great!


  81. Mike said: August 10, 2025 at 9:02 am | Permalink

    A very nice and simple tool! Is there a way to animate the moving function after a timeoout?


  82. Marla Silker said: August 18, 2025 at 2:49 pm | Permalink

    When i quite prefer whatever you submit in this article. Extremely useful in addition to smart. Just one challenge though. I’m running Internet explorer having Debian in addition to elements of this present web design portions undoubtedly are a very little wonky. When i understand it’s an excellent normal established. Yet still it’s an issue to help retain in view. When i trust so it can guide in addition to always keep in the prime excellent publishing.


  83. Anders said: August 19, 2025 at 6:46 pm | Permalink

    Great tutorial, and just a genius bit of jQuery 😉 I love looking over people’s code to see what they’ve done and it’s very nicely coded! So SIMPLE. Thanks for the script it’s awesome.


  84. Julián said: August 20, 2025 at 6:24 pm | Permalink

    How can i make it work in a WordPress page, i tried and it did worked!


  85. suplementy said: September 8, 2025 at 9:32 pm | Permalink

    Some really wonderful posts on this web site , appreciate it for contribution.


  86. Cheap UGG sale said: September 8, 2025 at 10:25 pm | Permalink

    I concede, I have not been on this site for a long time, however, it was another pleasure to see such an important issues and neglect it. Thanks for assisting making people realize that best issues.


  87. suknie ślubne radom said: September 8, 2025 at 11:21 pm | Permalink

    It’s best to participate in a contest for one of the best blogs on the web. I’ll advocate this website!


  88. Nightclub Dresses said: September 10, 2025 at 3:47 pm | Permalink

    Thank you for your wonderful post! It has long been very valuable. I hope which you will proceed sharing your wisdom with us.


  89. 8mediaeg said: September 12, 2025 at 10:46 am | Permalink

    amazing ,, i like it ,,


  90. Abbott said: September 15, 2025 at 9:25 am | Permalink

    forums which are above the same subject matter? Thank you!


  91. gulflee said: September 17, 2025 at 2:38 pm | Permalink

    thank you for the idea, is there a way to control the height of each eab content? dynamic i mean, it seem the height is following the highest tab-content. any idea.. thank u


  92. Nick said: October 3, 2025 at 11:31 pm | Permalink

    How to initializing selected tab? Please help… ;-(


  93. econ said: October 10, 2025 at 9:31 am | Permalink

    ‘cute’ it’s really help full
    thank you


  94. Ron L. said: October 16, 2025 at 6:40 pm | Permalink

    It doesn’t work well. I made 26 tabs (alphabet) and the tabs content are all over the place. It seems to work well until 8th


  95. Peter Klauer said: October 22, 2025 at 8:09 am | Permalink

    Great!!

    But we put some forms into the sliders and after saving always the starting slider was shown. This was a “jumping” effect. If the user fills some data into a slided form it would be nice if that form would be shown after reload.

    So I wrote a litte function “gotab” which “goes” to a specific tab.

    All you need to do is to put an id in the .tab_item span which needs some positioning:

    Termine

    To position to the tab “tab-kurse” after saving some data, PHP makes a string $js which is injected into the $(document).ready() at page-building time.

    $js = ‘ TabbedContent.gotab($(“#tab-termine”)); ‘;

    And here is the gotab function:
    (Pleas notice the comma at the beginning, which allows pasting into tabbedContent.js)

    ,

    gotab: function( obj ) {

    var background = $(obj).parent().find(“.moving_bg”);

    $(background).stop().animate({
    left: $(obj).position()[‘left’]
    }, {
    duration: 300
    });

    TabbedContent.slideContent( $(obj) );

    }

    As you see it is a simple variation of init().

    @Ron L.: Look in the CSS. Make .tabslider 180000px wide.


  96. praveen kumar said: November 11, 2024 at 12:55 pm | Permalink

    Thanksz ..a lott,

    for your nice “tabbed Content” , really a nice source


  97. Sharon said: January 17, 2025 at 12:17 am | Permalink

    Hi Peter Klauer, I really need the functionality you made and love using these tabs, but I cannot get it to work using your, would you be so kind as to post up your source files so I can see it in action? I have been trying for hours! Thank you.


  98. Su Wai said: February 11, 2025 at 5:31 am | Permalink

    Hello! That’s very great.
    But, Excuse me! I want to ask a question?
    I used these tabs in my asp.net project.
    But there is a problem. Current hovered tab index is lost after full postback and only first tab is selected. How do I slove this problem? Please!


  99. James said: February 23, 2025 at 8:34 pm | Permalink

    Has anyone achieved the auto height adjustment for each tab?
    That is the only thing missing.
    Thanx


  100. Andrey villegas said: March 2, 2025 at 11:12 pm | Permalink

    hello,excellent work.

    Thanks

    I have a question
    How I can make deslisen tabs vertically?


  101. Andrey villegas said: March 2, 2025 at 11:14 pm | Permalink

    excellent work
    thanks
    I have a question
    How I can make the tabs to slide vertically?


  102. Jeff said: March 19, 2025 at 9:57 pm | Permalink

    Have a demo site that is performing well in IE8 and IE9, also in
    latest Firefox, Chrome, Safari and Opera browsers for Windows. But all horizontal slider content disappears in IE7. I do believe there could be a JQuery conflict but am not sure. Would appreciate a few more eyeballs on this as I know I am overlooking something obvious.

    http://www.romdev.net/demo/


  103. Anikesh haran said: March 21, 2025 at 8:44 am | Permalink

    hi .. very nice work.
    But i have a query,
    cuurent code contain 4 tab in x-axis , and i want to add more tabs in x-axis. , but wath happen is , when i adding more tab , are align to second row. how to do ?


  104. Yasser said: March 22, 2025 at 11:45 am | Permalink

    this is really great.

    One Question:

    how can I change the text of the tab that is getting the focus ? I need the normal tabs to be in Black and the active one is white.

    can you help me with that?


  105. Stryker said: March 22, 2025 at 11:15 pm | Permalink

    Great Tutorial. But anyone got it working with the current JQuery-Version (1.6). The Version used in the tutorial (1.3) is pretty old… 😉


  106. Kelsey said: April 2, 2025 at 6:47 pm | Permalink

    Is there a good way to add more tabs? I figured out how to do 26 (alphabet), but now I want to use it with larger tabs names and don’t know how to make them fit. Can I add a second row of tabs? And how would I do this? I am new to jquery….


  107. MedanShare said: April 16, 2025 at 4:26 pm | Permalink

    AMAZING!!!
    great job.


  108. payroll software said: April 19, 2025 at 6:47 am | Permalink

    this is really great.

    One Question:

    how can I change the text of the tab that is getting the focus ? I need the normal tabs to be in Black and the active one is white.

    can you help me with that?


  109. payroll software said: April 19, 2025 at 6:48 am | Permalink

    this is really great.

    bt its possible to make the tabs to slide vertically?


  110. Lilian said: April 19, 2025 at 8:36 pm | Permalink

    It’s amazing!!!
    Thank you very much!!


  111. Julien said: April 21, 2025 at 7:26 am | Permalink

    Hi
    Is it possible to make the slidder work with different sized tabs?
    My first tab is 55px and the others are all the same size 90px
    Is this possible? If yes how?
    Thank you so much


  112. David said: May 8, 2025 at 4:06 pm | Permalink

    Is there a WordPress slider plugin we could implement this on? I would hate to think that anyone is hard coding sliders if they are using a CMS . The slides should be created with a custom post type and there should be a slider file called into the theme that pulls all the slides into the site..


  113. Cheltenham Web Design said: May 10, 2025 at 10:17 am | Permalink

    This is a very impressive bit of code. It looks slick and works very well.

    Thank you for the share.


  114. Diehl Designs said: May 11, 2025 at 6:15 pm | Permalink

    Love the slider! Thank you for sharing. Works great for a lot of scenarios.

    Is there a way to make it autoplay?


  115. Kashif Riaz said: May 16, 2025 at 8:21 am | Permalink

    This Tutorial Is Wonder Full.But I Got Some Problems In chrome Browser…When I Applied It To My Website The Tabbed Conttent Not Rotating..Any One Tell Me Solution


  116. Kiran said: May 17, 2025 at 6:52 pm | Permalink

    Hi, I am using this tab menu but i am facing some problem. There are total 7 tabs. I used dropdownlist in 4th or any other tab except one. selecting item from dropdown i am again going back to 1st tab but i have to stick with the current tab only. Can anyone please help me. I also used update panel but its showing me the same result.


  117. Ricardo said: June 3, 2025 at 12:43 am | Permalink

    Thank you!
    If you would like to add padding to the ul element, i recommend you that change this line:
    var margin = $(obj).parent().parent().find(“.slide_content”).Width();

    to this:
    var margin = $(obj).parent().parent().find(“.slide_content”).innerWidth();

    @prahalad
    If you want , you can change height property to auto in your css.
    I do a loop and i add a index to each tab and ul element.
    Then I calculate the height of each ul element and when each tab ittem is clicked i change the height

    $(“.tabslider ul”).each(function(i){
    $(this).addClass(‘ulIndex’ + i);
    });

    $(“.tab_item”).each(function(i){
    $(this).addClass(‘tabIndex’ + i);
    });

    $(‘.tab_item’).each(function(i){
    if($(this).hasClass(‘tabIndex’ + i))
    {
    var primera = $(‘.tabslider .ulIndex’ + 0).height();
    $(‘.tabslider’).height(primera);
    }
    $(this).click(function()
    { if($(this).hasClass(‘tabIndex’ + i))
    {
    var primera = $(‘.tabslider .ulIndex’ + i).height();
    $(‘.tabslider’).height(primera);
    var bodyTamano = $(‘body’).height();

    }
    });
    });

    I hope i have help you guys.


  118. Ricardo said: June 3, 2025 at 12:47 am | Permalink

    Sorry if i’ve made some mistakes in English.


  119. Carlos said: June 5, 2025 at 11:46 am | Permalink

    @ricardo

    I have tried your solution to change the eight based on each ul content but it doesn’t seem to work.

    In my CSS, I’ve included

    height = auto;

    to .tabslider

    but the overall height is still based in the default’s tab content. BTW, in my case I use mouseover to move the tab selector: does this make any difference?

    Thank you.


  120. Carlos said: June 5, 2025 at 11:47 am | Permalink

    Sorry, I obviously meant height: auto;


  121. PR Agency said: June 7, 2025 at 10:21 am | Permalink

    Beautiful sliding mechanism, seamless and smooth. A massive thanks for the share – great to see the community helping!


  122. Wirtualne spacery said: June 15, 2025 at 3:57 pm | Permalink

    That’s solution I was looking for.


  123. Ricardo said: June 25, 2025 at 7:08 pm | Permalink

    @Carlos
    i made a few changes to the code. This code uses the event mouseover like you wanted and
    Take a look.

    //tab effects

    var TabbedContent = {
    init: function() {
    $(“.tab_item”).mouseover(function() {
    $(‘.tabs’).find(‘.active’).removeClass(‘active’);

    if(!$(this).hasClass(‘active’))
    {
    $(this).addClass(‘active’);
    }

    TabbedContent.slideContent($(this));

    });
    },

    slideContent: function(obj) {

    var margin = $(obj).parent().parent().find(“.slide_content ul”).innerWidth();

    margin = margin * ($(obj).prevAll().size() – 1);
    margin = margin * -1;

    $(obj).parent().parent().find(“.tabslider”).stop().animate({
    marginLeft: margin + “px”
    }, {
    duration: 300
    });
    }
    }

    //put this part of the code before closing the body tag.

    $(document).ready(function() {
    TabbedContent.init();
    });

    $(‘.tab_item’).each(function(i){
    if($(this).hasClass(‘tabIndex’ + i))
    {
    var primera = $(‘.tabslider .ulIndex’ + 0).height();
    $(‘.tabslider’).height(primera);
    }
    $(this).mouseover(function()
    { if($(this).hasClass(‘tabIndex’ + i))
    {
    var primera = $(‘.tabslider .ulIndex’ + i).height();
    $(‘.tabslider’).height(primera);
    var bodyTamano = $(‘body’).height();
    }
    });
    });

    I calculate height with jQuery. I change width each time you put your mouse over each tab item.

    Hope i helped you. If you have questions , just ask again 😉

    Check out this live example.

    http://bit.ly/MklRxh


  124. Ricardo said: June 25, 2025 at 7:11 pm | Permalink

    Sorry, the line
    “//put this part of the code before closing the body tag.”
    goes after

    $(document).ready(function() {
    TabbedContent.init();
    });


  125. RIJO said: July 5, 2025 at 2:21 pm | Permalink

    Awesome.and perfectly done… Expecting few more in future.


  126. Daria said: September 19, 2025 at 8:45 pm | Permalink

    Ricardo, I tried implementing your code so that the content lines up correctly with the fifth tab, and for some reason when I do the content does not move at all. What am I doing wrong?


  127. Martin said: October 15, 2025 at 5:19 pm | Permalink

    First 10x for posting this. It is great. However i need some help.
    I tried to make it work in a wordpress page, and it does not work.
    http://plast-market.net/%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80%D0%BD%D0%B0-%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0-%D0%BD%D0%B0-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82/

    This is the page. If you can help me i will by you an online beer 🙂


  128. Jeff said: October 16, 2025 at 5:13 pm | Permalink

    I have to say I’ve been looking for something like this for some time now. Took me a little while to tweak it, but I’m very satisfied. Thanks for your hard work on creating this.


  129. mostafa said: October 22, 2025 at 10:15 pm | Permalink

    Hi,
    thank you for thus share.

    now, first tab show in start.
    please tell me, How i show “last TAB” first?

    thank you again.


  130. JC said: December 11, 2024 at 11:59 pm | Permalink

    Per #123 from Ricardo –

    Has someone gotten Ricardo’s changes to work? If so, could someone clarify something for me?

    I attempted to replace the code in the js file with his, but when I get to this part…

    //put this part of the code before closing the body tag.

    $(document).ready(function() {
    TabbedContent.init();
    });

    $(‘.tab_item’).each(function(i){
    if($(this).hasClass(‘tabIndex’ + i))
    {
    var primera = $(‘.tabslider .ulIndex’ + 0).height();
    $(‘.tabslider’).height(primera);
    }
    $(this).mouseover(function()
    { if($(this).hasClass(‘tabIndex’ + i))
    {
    var primera = $(‘.tabslider .ulIndex’ + i).height();
    $(‘.tabslider’).height(primera);
    var bodyTamano = $(‘body’).height();
    }
    });
    });

    I’m not sure what to do with it. I tried to place this code underneath this statement

    $(document).ready(function() {
    TabbedContent.init();
    });

    in the js file.

    I know it says to place the code before the closing body tag, but the entire code has been in the file, why does it need to be placed in the html?

    Any clarification would be greatly appreciated. Thanks.


  131. awan said: January 20, 2025 at 8:31 am | Permalink

    awesaome br 😀 ,, permite to Copy 😀


  132. Behrouz said: February 9, 2025 at 1:28 am | Permalink

    I cant find the index.html, Could you please tell me how can i make it?


  133. erinc said: February 10, 2025 at 5:20 pm | Permalink

    thanks Gaya, it working awesome. But, is there an option to remember the last tab opened or jump to specific tab instead of the first one.
    as something mentioned in post #25.


Leave a Comment

Your email is never shared. Get your own avatar with gravatar! Required fields are marked *

*

*