Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jquery - external tab link

Status
Not open for further replies.

ag1060

Programmer
Aug 26, 2011
27
0
0
US
Hello,

I have this jquery code for creating tabs but I'm having a hard time figuring out how to make them external (such as bookmark them by going #reg).

This is what I have:

Code:
$(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>
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}
#tabs {
	font: verdana;
	font-size: 90%;
	margin: 20px 0;
}
#tabs ul {
	float: left;
	background: #fff;
	width: 500px;
	padding-top: 4px;
}
#tabs li {
	margin-left: 8px;
	list-style: none;
}
* html #tabs li {
	display: inline;
}
#tabs li, #tabs li a {
	float: left;
}
#tabs ul li.active {
	border-top:2px; solid;
	background: #808080;
	
}
#tabs ul li.active a {
	color: #FFFFFF;
}
#tabs div {
	background: #FFFFFF;
	clear: both;
	padding: 15px;
	min-height: 200px;
}
#tabs div h3 {
	margin-bottom: 12px;
}
#tabs div p {
	line-height: 150%;
}
#tabs ul li a {
	text-decoration: none;
	padding: 8px;
	color: #000;
	font-weight: bold;
}
.thumbs {
	float:left;
	border:#000 solid 1px;
	margin-bottom:20px;
	margin-right:20px;
}
-->
</style>
</head>

<div id="container">
  <div id="tabs">
    <ul>
      <li><a href="#tab-1">About</a></li>
      <li><a href="#tab-2">Advertising</a></li>
      <li><a href="#tab-3">Contact</a></li>
    </ul>
    <div id="tab-1">
      <h3>About Tab-1</h3>
      <p>Tab-1 description.</p>
	
	</div>
    <div id="tab-2">
      <h3>Advertising</h3>
For inquiries regarding advertising, please send an email.
    </div>
    <div id="tab-3">
      <h3>Comtact</h3>
  Got questions or feedback for us? Feel free to send them.
	</div>

  </div>
</div>

I'm trying to make it where I can link them externally such as tab-2#, #tab-3#, etc. Thanks in advance.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top