Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<span class="showResults result_1">1</span>
<span class="showResults result_2">2</span>
<span class="showResults result_3">3</span>
<span class="showResults result_4">4</span>
<span class="showResults result_5">5</span>
<span class="showResults result_6">6</span>
<span class="showResults result_7">7</span>
<span class="showResults result_8">8</span>
<span class="showResults result_9">9</span>
<span class="showResults result_10">10</span>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
  <button class='showMore'>Show more</button>
</body>
</html>
 
  $(document).ready(function(){
        var initialresults = 5;
        var counter = 0;
        while (counter < initialresults){
            $('.' + counter).show();        
            counter++;
        };
        $(".showMore").click(function(e){
            e.preventDefault();
            console.log('initialResults is undefined', initialresults)
            var numberShowing = $('.showResults:visible').length;
            console.log(numberShowing); //5
            var visibleResults = numberShowing + 5
            var counter = 0;
                      console.log('after setting as variable', initialresults)
            while (counter <= visibleResults){
                $('.result_' + counter).css('display', 'block');        
                counter++;
            }
        })
  });
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers