Solved

Adding a class to a tab panel when the tab is selected

Posted on 2014-10-22
3
128 Views
Last Modified: 2015-01-02
How would i add a script that would add .z-index to the tab-panel that is active?

This is what i have:

<ul class="nav nav-pills pills-round" role="tablist" id="myTab">
<li class="active col-sm-4">Amount<a href="#tab1" role="tab" data-toggle="pill"><span>1</span></a></li>
<li class="col-sm-4"><hr>Name<a href="#tab2" role="tab" data-toggle="pill"><span>2</span></a></li>
<li class="col-sm-4"><hr>Payment<a href="#tab3" role="tab" data-toggle="pill"><span>3</span></a></li>
</ul>

When you select a tab, it opens a panel:

<div class="tab-content" id="myTabContent">
   <div class="tab-pane" id="tab1"></div>
    <div class="tab-pane" id="tab2"></div>
    <div class="tab-pane" id="tab2"></div>
</div>

I tried this script but it doesn't work. Any ideas?

$('.pills-round>li>a').click(function(){
$('.z-index').removeclass('z-index');
$('.active').addclass('z-index');
});
0
Comment
Question by:Miriam Fisher
3 Comments
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 40397387
z-index is a reserved word (it is a css property name) you should change that to something else.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery keyup 4 25
jQuery slideToggle working incorrectly 3 29
Responsive Font Size 6 30
Prevent a display:none image from downloading on page load 5 41
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question