Is there a way to display only 5 images from a list on the first load, and then show all images when the user clicks on "load more"?
Here is the code I have:
$('.photos-list').hide();
$('.photos-list').slice(1, 5).show();
$('#loadAllImages').click(function(){
$('.photos-list').show();
});
.photos-list ul,
.videos-list ul {
margin: 0px;
padding: 0px;
}
.photos-list ul li,
.videos-list ul li {
list-style: none;
float: left;
width: 18%;
margin: 5px;
position: relative;
}
.photos-list ul li img,
.videos-list ul li img {
width: 100%;
border-radius: 10px;
height: 110px;
}
.photos-list ul li span,
.videos-list ul li span {
position: absolute;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, .5);
padding: 5px 10px;
cursor: pointer;
}
.photos-list ul li span svg,
.videos-list ul li span svg {
color: #fff;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="photos-list">
<ul>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
<li> <img src="https://picsum.photos/200"/></li>
</ul>
<button type="button" id="loadAllImages">Load all Images</button>
</div>
Thank you for any assistance provided!