deepak-rajpal
3/19/2013 - 1:17 PM

Tabs using jquery. Using <li>

Tabs using jquery. Using

  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>jQuery Tabs </title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
    <style>
    #tabs ul { padding-left:0px; }
    #tabs ul li { display:inline-block; border:1px solid;}
    </style> 
    <script type="text/javascript">
        $(document).ready(function(){
    	$('#tabs div').hide();
    	$('#tabs div:first').show();
    	$('#tabs ul li:first').addClass('active');
    	$('#tabs ul li a').click(function(){ 
    		$('#tabs ul li').removeClass('active');
    		$(this).parent().addClass('active'); 
    		var currentTab = $(this).attr('href'); 
    		$('#tabs div').hide();
    		$(currentTab).show();
    		return false;
    	});
    	});
    </script>
    </head>
    <body>
    <div id="container">
      <div id="tabs">
        <ul>
          <li><a href="#tab-1">Tab1</a></li>
          <li><a href="#tab-2">Tab2</a></li>
          <li><a href="#tab-3">Tab3</a></li>
        </ul>
        <div id="tab-1">
          <p> Nim. Nullam id ligula in nisl Lorem Curabitur eu magna </p>
        </div>
        <div id="tab-2">
          <p> Nullam id ligula in nisl tincidunt feugiat. Curabitur eu magna </p>
        </div>
        <div id="tab-3">
          <p> Curabitur enim. Nullam id ligula in nisl Lorem ipsum </p>
        </div>
      </div>
    </div>
    </body>
    </html>