Click here to Skip to main content
15,889,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using jQuery tabbedContent.But, after full postback, only first tab is selected(i.e., current tabindex is missing.).I used jquery.min.js(* jQuery JavaScript Library v1.3.2), tabbedContent.js and tabbedContent.css. How do I write it? Please!

//This is tabbedContent.js
C#
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(".tabslider").stop().animate({
            marginLeft: margin + "px"
        }, {
            duration: 300
        });
    }
}

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


//And this is tabbedContent.css
CSS
.tabbed_content {
    background-color: #000000;
    width: 620px;
}

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

.tabs .moving_bg {
    padding: 15px;
    background-color: LightSkyBlue;
    background-image:url(../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: #ffffff;
    text-align: center;
    z-index: 200;
    position: relative;
    cursor: pointer;
    font-size:small;
}

.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;
}



//And this is .aspx code
XML
<div class="tabbed_content">
                                    <div class='tabs'>
                                        <div class='moving_bg'>
                                            &nbsp;
                                        </div>
                                        <span class='tab_item'>Tab1</span><span class='tab_item'>Tab2</span>
                                        <span class='tab_item'>Tab3</span><span class='tab_item'>Tab4</span>
                                    </div>
                                    <div class='slide_content'>
                                        <div class='tabslider' align="left">
                                            <ul>
                                                <li>
                This is for Tab1.
            </li>
                                            </ul>
                                           <ul>
                                                <li>
                This is for Tab2.
            </li>
                                            </ul>
            <ul>
                                                <li>
                This is for Tab3.
            </li>
                                            </ul>
            <ul>
                                                <li>
                This is for Tab4.
            </li>
                                            </ul>
            </div>
                                    </div>
                                </div>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900