Giter VIP home page Giter VIP logo

itshadyy / load-more-button Goto Github PK

View Code? Open in Web Editor NEW

This project forked from solodev/load-more-button

0.0 0.0 0.0 9 KB

Showcasing your content on the web is more essential than ever but there's so much content and only so much real estate on a web page before the viewer stops scrolling. Web designers and developers have recognized this behavior in website visitors and implement different techniques to display content in the most intuitive way while still providing

CSS 28.45% HTML 71.55%

load-more-button's Introduction

load-more-button

Showcasing your content on the web is more essential than ever but there's so much content and only so much real estate on a web page before the viewer stops scrolling. Web designers and developers have recognized this behavior in website visitors and implement different techniques to display content in the most intuitive way while still providing the volume of content some visitors may require.

Your blog may have 1,000 entries but you don't want to show all of them on a single page or it will take an extremely long time to load and cause an information overload that may even increase your bounce rates. In the case of these 1,000 entries developers would likely "lazy load" any entries over a certain integer. In our example, we don't have 1,000 entries so a simple "Load More" button and some JavaScript will suffice. In this article, Solodev will teach you how to add a load more button to your content.

Tutorial

For detailed instructions, view Solodev's Adding a Load More Button to your Content article.

Demo

Try out a working example on JSFiddle.

HTML

The load more button contains the following HTML markup.

<div class="interior container clearfix">
   <div class="row"> 
      <div class="col-xs-12 col-sm-6 col-md-12 blogBox">
         <div class="item featured">
            <img src="https://www.solodev.com/assets/fancy/travel3.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Business Intelligence</a>
               </div>
               <h2>
                  Eu qui dolore altera, saepe molestie accusamus
               </h2>
               <p class="post_intro hidden-xs">
                  An erant partem albucius quo, ad graece latine atomorum sea, sit dicant laoreet at. Id has chor...
               </p>
            </div>
         </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 blogBox moreBox" >
         <div class="item">
            <img src="https://www.solodev.com/assets/fancy/travel5.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Virtual Reality</a>
               </div>
               <h2>
                  Ea delicata deterru isset concluda turque
               </h2>
               <p class="post_intro hidden-xs">
                  Mel ut enim atqui, ne eum tation populo delectus. Vim soluta insolens phaedrum et, lucilius par...
               </p>
            </div>
         </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 blogBox moreBox" >
         <div class="item">
            <img src="https://www.solodev.com/assets/fancy/travel6.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Internet of Things (IoT)</a>
               </div>
               <h2>
                  No vim quis quodsi, etiam quaestio euripidis
               </h2>
               <p class="post_intro hidden-xs">
                  Sed possim nonumes no, iuvaret similique quo no. Ut sea idque option aliquando. Ei mea choro ap...
               </p>
            </div>
         </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 blogBox moreBox" >
         <div class="item">
            <img src="https://www.solodev.com/assets/fancy/travel9.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Artifical Intelligence</a>
               </div>
               <h2>
                  Qui an alii magna consectetuer
               </h2>
               <p class="post_intro hidden-xs">
                  Ad populo appareat vulputate vix, ex fastidii signiferumque pro. In sea doming reprehendunt. Na...
               </p>
            </div>
         </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 blogBox moreBox" style="display: none;">
         <div class="item">
            <img src="https://www.solodev.com/assets/fancy/travel7.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Big Data</a>
               </div>
               <h2>
                  Integre voluptatum cu quo iriure docendi senserit
               </h2>
               <p class="post_intro hidden-xs">
                  Delicata inciderint at per, eu partem principes eum, illud nobis appetere ex his. Ei vix melior...
               </p>
            </div>
         </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 blogBox moreBox" style="display: none;">
         <div class="item">
            <img src="https://www.solodev.com/assets/fancy/travel8.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Growth Hacking</a>
               </div>
               <h2>
                  Pro brute causae aliquip ad
               </h2>
               <p class="post_intro hidden-xs">
                  No ipsum invidunt eos, ei ius dicit platonem perpetua. Mea te feugait ocurreret aliquando, ei i...
               </p>
            </div>
         </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 blogBox moreBox" style="display: none;">
         <div class="item">
            <img src="https://www.solodev.com/assets/fancy/travel2.jpg">
            <div class="blogTxt">
               <div class="blogCategory">
                  <a href="/">Content Marketing</a>
               </div>
               <h2>
                  Lorem ipsum dolor sit amet, consect adipiscing elit
               </h2>
               <p class="post_intro hidden-xs">
                  Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ...
               </p>
            </div>
         </div>
      </div>
      <div id="loadMore" style="">
         <a href="#">Load More</a>
      </div>
   </div>
</div>

CSS

All necessary CSS is included in the file load-more-button.css

JavaScript

The load more button utilizes the following JavaScript.

$( document ).ready(function () {
                $(".moreBox").slice(0, 3).show();
                if ($(".blogBox:hidden").length != 0) {
                        $("#loadMore").show();
                }               
                $("#loadMore").on('click', function (e) {
                        e.preventDefault();
                        $(".moreBox:hidden").slice(0, 6).slideDown();
                        if ($(".moreBox:hidden").length == 0) {
                                $("#loadMore").fadeOut('slow');
                        }
                });
        });

External Includes

This tutorial contains the following third party resources.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="load-more-button.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

load-more-button's People

Contributors

mattmclaren avatar smmadara avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.