Execute jquery animate only one time

Viewed 19412

I've the following function:

$('.link1').click(function(){
    $("#div2").slideUp(function(){$("#div1").slideToggle();});
    $('html, body').animate({scrollTop: '600px'}, 800);
});

It toggles a div and scroll the page down. The problem is that everytime the user toggles the page scroll down again...how could I run this animate function only at first click?

8 Answers

The following works with JQuery.

The CSS used:

.cpos {
    position: relative;
    top: -1.65em;
    left: 1.8em;
}

The JQuery used:

var p=null; /* Initialize variable p. */
p=$("b").detach(); /* Detach every possible <b>b</b>-tags. */
var p=$("<b>Console loaded!</b>").addClass("cpos"); /* Do anything, like adding class. */
p.appendTo("#container"); /* Append new data to the anchor container. */

Maybe you could use this for reference when animating. ;)

Related