event.preventDefault not working. Ajax call causing this?
<p>I'm trying to use scrolltop method and event.preventDefault is not working properly.
What I'm experiencing is that the page scrolls UP first then scrolls down.
It seems that The onclick causes the page to resubmit or something... (ajax post??)</p>

<p>I have following code</p>

<p>button (trigger)</p>

<pre><code> &lt;a id="nextset" class='nextbtn' &gt;Next Step&lt;/a&gt;
</code></pre>

<p>event</p>

<pre><code>jQuery('#nextset').click(function (event) {
                event.preventDefault();
                movenext('set');
                jQuery('html,body').animate({ scrollTop: $('#subtitles').offset().top }, 2000);
            });
</code></pre>

<p>functions</p>

<pre><code>    function getfav(obj) {
            var myParams = "{ 'proattr':'" + obj + "'}";
            jQuery.ajax({
                type: "POST",
                url: "project.aspx/getproject",
                data: myParams,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () { jQuery('#wait').show(); },
                complete: function () { jQuery('#wait').hide(); },
                success: function (msg) {
                    GetProjectPic(msg.d, obj); //creates DOM and insert in div
                    Initbtns();// dynamic btns initialization
                }
            });
        }

  function movenext(obj) {
            //other codes to hide/show DOM
            getfav(nextobj); 
        }
</code></pre>

<p>If I add return faulse; in onclick event, the button doesn't work.</p>

<p>Any idea what's causing the scrolling to the top?</p>

<p><strong>UPDATE:</strong></p>

<p>It was caused by code block inside movenext function.</p>

<pre><code>jQuery('[id^="favdiv"]').empty(); 
</code></pre>

<p>nothing to do with event.preventDefault.</p>

<p>The strange thing is that the screen scrolls much more than hidden div height ("favdiv") which causes up and down screen effect. I'm not sure how to prevent it...</p>

<p><strong>UPDATE2</strong></p>

<p>I searched jquery empty method and found this.</p>

<p><a href="http://stackoverflow.com/questions/9326757/jquery-empty-changes-the-scrollbar">jquery &quot;empty&quot; changes the scrollbar</a></p>
