Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  
  
  
  <ul id="tabs">
    <li><a href="#" name="tab1">T1</a></li>
    <li><a href="#" name="tab2">T2</a></li>
</ul>
<div id="content"> 
    <div id="tab1">
    TAB 1 CONTENT
    </div>
    <div id="tab2">
    TAB 2 CONTENT
    </div>
</div>
  
  
</body>
</html>
 
ul#tabs li.current{
  color:#f00;
}
 
$(document).ready(function() {
    $("#content div").hide().eq(0).show(); // show first one
    $("#tabs li").eq(0).addClass('current'); // set active one
    $('#tabs a').click(function(e) {
        e.preventDefault();
        if( $(this).closest("li").hasClass('current') ){ //detection for current tab
         return;      
        }else{             
            $("#content div").hide(); //Hide all content
            $("#tabs li").removeClass('current'); //Reset id's
            $(this).parent().addClass('current'); // Activate this
            $('#' + $(this).attr('name')).fadeIn(); // Show content for current tab
        }
    });
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers