Currently I have a very simple tab system set up, the problem is when the you click on the tabs the page moves upwards but not all the way to the top. I have tried return false; and e.preventDefault(); in my click event. None of these seem to be working. If anyone could help me stop the page move when a tab is clicked that would be great. Here is my code, also for know I just have the e.preventDefault(); in my click event but I have also tried the return false too :
$(".tab_content").hide();
$(".bat-tabs li:first").addClass("active").show();
$(".tab_content:first").show();
$("#nav-container").css("border-top", "3px solid #F79C0C");
$(".bat-tabs li > a").click(function (e) {
$(".bat-tabs li").removeClass("active");
$(this).parent().addClass("active");
$(".tab_content").hide();
var activeTab = $(this).attr("href");
$(activeTab).fadeIn();
e.preventDefault();
});
Here is my actual html
Thank you guys for both responding so quickly. For jbrookover: not sure how i should implement your solution bc right now for each one of my links i have a corresponding #+('tab name'), like this: { <div class="clearfix">
<ul class="bat-tabs clearfix">
<li><a href="#baseball" title="click to see all our choices for baseball bats" class="active"><h2>Baseball Bats</h2></a></li>
<li><a href="#fast" title="click to see all our choices for fastpitch bats"><h2>Fastpitch Bats</h2></a></li>
<li><a href="#slow" title="click to see all our choices for slowpitch bats"><h2>Slow Pitch Bats</h2></a></li>
</ul>
</div>
<div id="nav-container" class="section clearfix nav">
<div id="baseball" class="tab_content">
content here
</div>
<div id="fast" class="tab_content">
content here
</div>
<div id="slow" class="tab_content">
content here
</div>
</div> }