$(document).ready(function() {
// run test on initial page load
checkSize();
// run test on resize of the window
$(window).resize(checkSize);
});
//Function to the css rule
function checkSize(){
if ($("#nav-container").css("width") == "767px" ){
// your code here
var totalCount; //Keeps track of the total number of li's, shown or hidden.
var currentCount; //Keeps track of the number of li's currently shown.
$(document).ready(function () {
//Count how many li's there are in total.
totalCount = $('.thumbnails li').size();
//Start by showing three of them.
currentCount = 3;
adjustLiShown();
$('#loadMore').click(function () {
//Increase by three and update.
currentCount += 3;
adjustLiShown()
});
$('#showLess').click(function () {
//Decrease by three and update.
currentCount -= 3;
adjustLiShown()
});
});
function adjustLiShown() {
//Hide all and then show the one with index under total count.
$('.thumbnails li').hide().filter(':lt(' + currentCount + ')').show();
//Only show "load more" if we haven't reached the total yet.
$('#loadMore').toggle(currentCount < totalCount);
//Only show "show less" if we are above the starting number.
$('#showLess').toggle(currentCount > 3);
}
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.