1
Hello, everybody!
I would like to know how I can make several li’s be loaded only when the user clicks the "see more".
In the following example, I would like that, when accessing the page, only the first 2 li’s are visualized. To load the last 2 li’s, you would need to click on the "see more".
I refer to loading/optimizing the performance of the page opening time. I mean, I don’t just want to hide content with CSS.
<ul>
<li>
<a href="img/portfolio/1.jpg">
<img src="img/portfolio/1-thumbs.jpg">
</a>
</li>
<li>
<a href="img/portfolio/2.jpg">
<img src="img/portfolio/2-thumbs.jpg">
</a>
</li>
<div class="botao">Ver mais</div>
<li>
<a href="img/portfolio/3.jpg">
<img src="img/portfolio/3-thumbs.jpg">
</a>
</li>
<li>
<a href="img/portfolio/4.jpg">
<img src="img/portfolio/4-thumbs.jpg">
</a>
</li>
</ul>
This HTML is not very good because you have a
div
in the middle ofli
. That can be changed?– Sergio
Yes, Sergio. I used only as an example to say that the 2 last li’s will only be loaded after clicking this button (div).
– Will
If performance is the issue, you should use CSS. Changing the class of some li’s via JS should be faster than dynamically creating/removing an element in the DOM.
– Genos
ul original has 18 images (is a portfolio). So I thought about loading 6 out of 6 images. So the site doesn’t have to take long to open.
– Will
Because I added a preloader where it only allows the page to be viewed after it has been fully loaded.
– Will