jQuery fadeIn() jumps to top of page
<p>I've got custom jQuery tabs (not UI) that work great. However, since the tabs use <code>fadeIn()</code>, when you click the different tabs, it will jump to the top of the page. </p>

<p>I've looked at these two solutions (below) and it seems that setting the <strong>height</strong> does solve the jumping issue. However, I do not want to set the height statically. I've tried to dynamically set the height but I cannot make it work for some reason. I've also tried to load the content (<code>load()</code>) but cannot get it to work either.</p>

<p><a href="http://stackoverflow.com/questions/3574508/jquery-fade-making-page-jump">jQuery fade making page jump</a></p>

<p><a href="http://stackoverflow.com/questions/3832723/jquery-fadein-fadeout-image-on-click-jumps-while-loading-new-image">JQuery fadeIn/fadeOut image on click jumps while loading new image</a> </p>

<p>My <strong>HTML</strong> code is this:</p>

<pre><code>&lt;ul class="port-tabs"&gt;
&lt;li&gt;&lt;a href="#tab1"&gt;Web Design &amp;amp; Dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#tab2"&gt;Graphic Design&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#tab3"&gt;Photography&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="port-slides slides-list tab-container"&gt;
&lt;div id="tab1" class="port-subpages tab-content"&gt;
    &lt;ul class="portfolio"&gt;
  &lt;li&gt;
&lt;div id="port-window"&gt;
    &lt;span class="window"&gt;&lt;/span&gt;
    &lt;span class="gradient"&gt;&lt;/span&gt;
    &lt;a href="#"&gt;&lt;img src="http://localhost:8888/wordpress/wp-content/uploads/2012/07/port-image1.jpg" alt="" title="" width="223" height="225" class="alignnone size-full wp-image-112" /&gt;&lt;/a&gt;
&lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
&lt;div id="port-window"&gt;
    &lt;span class="window"&gt;&lt;/span&gt;
    &lt;span class="gradient"&gt;&lt;/span&gt;
    &lt;a href="#"&gt;&lt;img src="http://localhost:8888/wordpress/wp-content/uploads/2012/07/port-image2.jpg" alt="" title="" width="223" height="225" class="alignnone size-full wp-image-112" /&gt;&lt;/a&gt;
&lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
&lt;div id="port-window"&gt;
    &lt;span class="window"&gt;&lt;/span&gt;
    &lt;span class="gradient"&gt;&lt;/span&gt;
    &lt;a href="#"&gt;&lt;img src="http://localhost:8888/wordpress/wp-content/uploads/2012/07/port-image3.jpg" alt="" title="" width="223" height="225" class="alignnone size-full wp-image-112" /&gt;&lt;/a&gt;
&lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;
&lt;div id="port-window"&gt;
    &lt;span class="window"&gt;&lt;/span&gt;
    &lt;span class="gradient"&gt;&lt;/span&gt;
    &lt;a href="#"&gt;&lt;span class="port-just-text"&gt;TEXT PLACEHOLDER 1&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
&lt;div id="port-window"&gt;
    &lt;span class="window"&gt;&lt;/span&gt;
    &lt;span class="gradient"&gt;&lt;/span&gt;
    &lt;a href="#"&gt;&lt;span class="port-just-text"&gt;TEXT PLACEHOLDER 2&lt;/a&gt;
&lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
&lt;div id="port-window"&gt;
    &lt;span class="window"&gt;&lt;/span&gt;
    &lt;span class="gradient"&gt;&lt;/span&gt;
    &lt;a href="#"&gt;&lt;span class="port-just-text"&gt;TEXT PLACEHOLDER 3&lt;/a&gt;
&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p class="clearBoth"&gt;&lt;/p&gt; &lt;!-- Temporary fix: remove when live --&gt;
&lt;div id="tab3" class="port-subpages tab-content"&gt;
    &lt;p&gt;Tab Content 3&lt;/p&gt;
&lt;/div&gt;
</code></pre>

<p></p>

</p>

<p><strong>jQuery</strong> code is this:</p>

<pre><code>$(document).ready(function() {

    //When page loads...
    $(".tab-content").hide(); //Hide all content
    $("ul.port-tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab-content:first").show(); //Show first tab content


    //On Click Event
    $("ul.port-tabs li").click(function() {

        $("ul.port-tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab-content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        //activeHeight = $(activeTab).height();
        //alert(activeHeight);
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });
});
</code></pre>

<p>Can someone please help eliminate the jumping to the top upon clicking a new tab?</p>
