code show as below:
The above is the HTML structure. How to use JAVASCRIPT (not JQUERY) to only display 5 links and hide the rest. You need to click on the picture or text to display it, and then click to hide it. How can I achieve this function?
Currently displayed:
I am link 1
I am link 2
I am link 3
I am link 4
I am link 5
...
I am link 10
The effect you want to display:
I am link 1
I am link 2
I am link 3
I am link 4
I am link 5
︿ //Click here to expand the remaining "I am link" 6-10", then click to hide "I am the link 6-10".
Let’s talk about a stupid way, asynchronous request. Load only what you need first, click the button to request the rest, and dynamically load it into the page. Add a class to the newly added li for click hiding.
The code is rather ugly, please forgive me (using jquery api)
After reading the above answers, I don’t think they are my thoughts. Let’s talk about mine here
Every time you call loadNode(), pass in the number of li to be generated as a parameter, and it can be generated dynamically
I can’t quite understand what you mean
css:
Set a reserved classname for li, such as .hide {display:none}
Now add hide to the following li classes
js:
Use the click event to trigger to determine whether there is a hide, and then delete the class or add the class according to the situation.
Probably this is the route.
The idea is to let ul overflow:hidden and then change the height.
Wrote a draft https://jsfiddle.net/straybug...