Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head></head>
<body>
    <a id="x" href="#" style="position:fixed; top:0; right:10px;">Switch</a>
    <div id="a">
        <p>Huge paragraph 1</p>
    </div>
    <div id="b" style="display:none;">
        <p>Huge paragraph 2</p>
    </div>
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script>
        (function(){
            var top;
            $('#x').click(function() {
                var temp;
                temp = $('body').scrollTop();
                console.log(temp);
                console.log(top);
                $('#a').toggle();
                $('#b').toggle();
                
                if(top !== undefined){
                    $('body').scrollTop(top);
                }
                top = temp;
                return false;
            });
        }());
    </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers