Created
March 19, 2013 13:17
-
-
Save deepak-rajpal/5196026 to your computer and use it in GitHub Desktop.
Tabs using jquery. Using <li>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment