I have created the jquery tabs.
<div id="tabs_container">
<ul id="tabs">
<li class="active"><a href="#tab1">Allgemeines</a></li>
<li><a href="#tab2">Kontakt</a></li>
<li><a href="#tab3">Musik</a></li>
<li><a href="#tab4">Hauptfoto</a></li>
<li><a href="#tab5">Einstellungen</a></li>
</ul>
</div>
<div id="tabs_content_container">
<div id="tab1" class="tab_content" style="display: block;">
<?php include('1.php'); ?>
</div>
<div id="tab2" class="tab_content">
<?php include('2.php'); ?>
</div>
<div id="tab3" class="tab_content">
<?php include('3.php'); ?>
</div>
<div id="tab4" class="tab_content">
<?php include('4.php'); ?>
</div>
<div id="tab5" class="tab_content">
<?php include('5.php'); ?>
</div>
</div>
</div>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){
$("#tabs li").click(function() {
// First remove class "active" from currently active tab
$("#tabs li").removeClass('active');
// Now add class "active" to the selected/clicked tab
$(this).addClass("active");
// Hide all tab content
$(".tab_content").hide();
// Here we get the href value of the selected tab
var selected_tab = $(this).find("a").attr("href");
// Show the selected tab content
$(selected_tab).fadeIn();
// At the end, we add return false so that the click on the link is not executed
return false;
});
});
/* ]]> */
</script>
I need to tab selected from url that means if .php#tab2
tab 2 a active tab. #tab3 then tab 3 a active tab. How can I achieve this?
I have created the jquery tabs.
<div id="tabs_container">
<ul id="tabs">
<li class="active"><a href="#tab1">Allgemeines</a></li>
<li><a href="#tab2">Kontakt</a></li>
<li><a href="#tab3">Musik</a></li>
<li><a href="#tab4">Hauptfoto</a></li>
<li><a href="#tab5">Einstellungen</a></li>
</ul>
</div>
<div id="tabs_content_container">
<div id="tab1" class="tab_content" style="display: block;">
<?php include('1.php'); ?>
</div>
<div id="tab2" class="tab_content">
<?php include('2.php'); ?>
</div>
<div id="tab3" class="tab_content">
<?php include('3.php'); ?>
</div>
<div id="tab4" class="tab_content">
<?php include('4.php'); ?>
</div>
<div id="tab5" class="tab_content">
<?php include('5.php'); ?>
</div>
</div>
</div>
<script type="text/javascript">
/* <![CDATA[ */
$(document).ready(function(){
$("#tabs li").click(function() {
// First remove class "active" from currently active tab
$("#tabs li").removeClass('active');
// Now add class "active" to the selected/clicked tab
$(this).addClass("active");
// Hide all tab content
$(".tab_content").hide();
// Here we get the href value of the selected tab
var selected_tab = $(this).find("a").attr("href");
// Show the selected tab content
$(selected_tab).fadeIn();
// At the end, we add return false so that the click on the link is not executed
return false;
});
});
/* ]]> */
</script>
I need to tab selected from url that means if http://example./settings.php#tab2
tab 2 a active tab. #tab3 then tab 3 a active tab. How can I achieve this?
Share Improve this question edited Aug 7, 2012 at 19:01 gilly3 91.9k26 gold badges147 silver badges179 bronze badges asked Aug 7, 2012 at 18:54 CodesenCodesen 7,8425 gold badges30 silver badges31 bronze badges3 Answers
Reset to default 6$(document).ready(function(){
$(".active").removeClass("active");
$(document.location.hash).addClass("active");
});
window.onhashchange
use the above native code. it will trigger when there is a hash change in the url
window.onhashchange=function(){
if(document.location.hash ==="#tab2"){
//write your code here
}
}
Hope it will help.
http://jsfiddle/AavsW/21/
$('#wizard').tabs({ disabled: [1, 2] });
try this i hope it will solve your problem