How to perform the default link action after the specified action with Jquery?
<p>I have a "slide out" div that I'm hiding/showing via CSS positioning, and using jquery to toggle a class that sets the hidden/shown state of the div. </p>

<p>That's all working great.  What I'm now trying to do is have any link farther up on the page change the class to show the div, and jump down the page to it.</p>

<p>Here's what I have :</p>

<pre><code>$('a[href="#request-trial"]').click(function () {
  $("#request-trial").toggleClass("on off");
});         
</code></pre>

<p>The problem is it's first jumping to the anchor, and then changing the class, so it's jumping to the position of the div when it's "off" instead of when it's "on" - does that make sense?  Does anyone have any suggestions?</p>

<hr>

<p>adding some extra info:</p>

<p>HTML:</p>

<pre><code>&lt;section class="form-popup on" id="request-trial"&gt;
&lt;div class="container"&gt;
&lt;h1&gt;Let's Talk more!&lt;/h1&gt;
&lt;p&gt;Have a project in mind or have an organizational challenge you need assistance in tackling? Get in touch... we’ll discuss ways that the Beyond Nines team could help.&lt;/p&gt;

&lt;a class="close"&gt;Close&lt;/a&gt;
&lt;/div&gt;
&lt;/section&gt;
</code></pre>

<p>Link is something like:</p>

<pre><code>&lt;a href="#request-trial"&gt;Sign up&lt;/a&gt;
</code></pre>

<p>Css: </p>

<pre><code>.form-popup,
.form-popup.on {
position: absolute;
height: 500px;
z-index: 0;
bottom: 0px;
opacity: 1;
 }

 .form-popup.off {

 bottom: -580px;
 opacity: 0;

  }
</code></pre>
