When more and less links click, list items show/hide using Jquery?

This does what I think you want and it is a lot cleaner, you were doing a lot more jQuery calls than were needed.

This does what I think you want and it is a lot cleaner, you were doing a lot more jQuery calls than were needed. JQuery(function($) { var visible = 7, $lis = $('ul li'), max = $lis. Length; function showUpToIndex(index) { $lis.hide(); $lis.

Slice(0, index).show(); } showUpToIndex(visible); $('#more'). Click(function(e) { e.preventDefault(); visible = visible + 5; if (visible > max) visible = max; showUpToIndex(visible); }); $('#less'). Click(function(e) { e.preventDefault(); visible = visible - 5; if (visible.

So the problem is with your currentIndex in your less function. It is finding the index of the VISIBLE elements only, not the index of your FIRST li that is visible out of ALL your elements, if you see what im saying. @Richard D's answer looks good to me, but if you wanted to know where your problem was I believe it starts there.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions