Repeating code pointers?
<p>I was wondering if anyone can help me out, please.
I have this code (see below) and I want to stop repeating the code over and over. Yes I'm a beginner, go easy on me. Many thanks in advance.</p>

<pre><code>$(function() {
    $('#showdiv1').click(function() {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
         $('div[id^=div]').slideUp().delay(1000);
          $('#div1').slideDown('slow').delay(1000);

    });

    $('.upper').click(function() {
      $('html, body').animate({ scrollTop: 0 }, 'slow');
       $('#div1').slideUp('slow');
    });


    $('#showdiv2').click(function() {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
          $('div[id^=div]').slideUp().delay(1000);
            $('#div2').slideDown('slow').delay(1000);
    });

     $('.upper').click(function() {
       $('html, body').animate({ scrollTop: 0 }, 'slow');
        $('#div2').slideUp('slow');
    });

    $('#showdiv3').click(function() {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
         $('div[id^=div]').slideUp().delay(1000);
          $('#div3').slideDown('slow').delay(1000);
    });

     $('.upper').click(function() {
       $('html, body').animate({ scrollTop: 0 }, 'slow');
        $('#div3').slideUp('slow');
    });

    $('#showdiv4').click(function() {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
         $('div[id^=div]').slideUp().delay(1000);
          $('#div4').slideDown('slow').delay(1000);

    });

    $('.upper').click(function() {
       $('html, body').animate({ scrollTop: 0 }, 'slow');
        $('#div4').slideUp('slow');
    });
</code></pre>
