开发者

Make a new set of working tabs and panes for another div

This is my css:

ul.tabs { 
    list-style:none; 
    margin: 0!important; 
    padding:0;    
    border-bottom:0px solid #666;    
    height:30px;
}

/* single tab */
ul.tabs li { 
    float:left;     
    text-indent:0;
    padding:0;
    margin:0 !important;
    list-style-image:none !important; 
}

/* link inside the tab. uses a background image */
ul.tabs a {
    background-color: #000000;
    font-size:12px;
    display:block;
    height: 30px;
    line-height:30px;
    width: 134px;
    text-align:center;
    text-decoration:none;
    color:#FFFFFF;
    padding:0px;
    margin:0px;
    position:relative;
    background-image: url();
    background-repeat: no-repeat;
    background-position: -420px 0;
    font-family: arial;
    font-weight: bold;
    text-transform: uppercase;
}


ul.tabs a:active {
    outline:none;        
}

/* when mouse enters the tab move the background image */
ul.tabs a:hover {
    background-position: -420px -31px;    
    color:#fff;    
}

    /* active tab uses a class name "current". 
its highlight is also done by moving the background image. */
    ul.tabs a.current, ul.tabs a.current:hover, ul.tabs li.current a {
        background-position: -420px -62px;        
        cursor:default !important; 
        color:#000 !important;
    }


/* initially all panes are hidden */ 
.panes .pane {
    display:none;        
}

.panes div {
    display:none;
    padding:15px 10px;
    border:medium solid #000000;
    height:150px;
    font-size:14px;
    background-color: #0099FF;
}

This is my HTML:

<div class="panes">
    <div>working pane 1</div>
    <div>working pane 2</div>
    <div>working pane 3</div>
</div>   

<ul class="tabs">
    <li><a href="#">Working Tab1</a></li>
    <li><a href="#">Working Tab2</a></li>
    <li><a href="#">Working Tab3</a></li>
</ul>
<p>

<div class="Next Set of Tabs I want to work">
  <ul class="tabs">
    <li><a href="#">tab 1</a></li>
    <li><a href="#">tab 2</a></li>
</ul>

<div class="Next Set of Panes I want to work">
    <div>member pane 1</div>
    <div>mem开发者_StackOverflowber pane 2</div>
    <div>member pane 3</div>
</div> 
</div

and this is my javascript:

// perform JavaScript after the document is scriptable.
$(function() {
    // setup ul.tabs to work as tabs for each div directly under div.panes
    $("ul.tabs").tabs("div.panes > div");
});
</script>

How do I create a 2nd and 3rd set of tabs and panes that I can use elsewhere in my document? Ive tried some edits of my own but I failed miserably.

Also, what changes do I have to make to my javascript so that it will work for the added tabs and panes in addition to the current one?

Please reply with example in code. Thanks in advance.


You've not provided any details on which jQuery plugin you're using. However, if you're using the jQuery Tools "Tabs" plugin, then I suggest you run through the tabs plugin with an .each() loop, and get the panes with unique references.

$(function() {
$('.tabs').each(function() {
$(this).tabs($(this).prev('.panes'))
});

Sorry if this is quite vague; but we could do with more details on the plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜