onclick show 10 elements

Solutions on MaxInterview for onclick show 10 elements by the best coders in the world

showing results for - "onclick show 10 elements"
Noreen
04 Apr 2017
1$(document).ready(function () {
2    size_li = $("#myList li").size();
3    x=3;
4    $('#myList li:lt('+x+')').show();
5    $('#loadMore').click(function () {
6        x= (x+5 <= size_li) ? x+5 : size_li;
7        $('#myList li:lt('+x+')').show();
8    });
9    $('#showLess').click(function () {
10        x=(x-5<0) ? 3 : x-5;
11        $('#myList li').not(':lt('+x+')').hide();
12    });
13});
14
Adem
23 Oct 2020
1$(document).ready(function () {
2    size_li = $("#myList li").size();
3    x=3;
4    $('#myList li:lt('+x+')').show();
5    $('#loadMore').click(function () {
6        x= (x+5 <= size_li) ? x+5 : size_li;
7        $('#myList li:lt('+x+')').show();
8         $('#showLess').show();
9        if(x == size_li){
10            $('#loadMore').hide();
11        }
12    });
13    $('#showLess').click(function () {
14        x=(x-5<0) ? 3 : x-5;
15        $('#myList li').not(':lt('+x+')').hide();
16        $('#loadMore').show();
17         $('#showLess').show();
18        if(x == 3){
19            $('#showLess').hide();
20        }
21    });
22});
23