G
G
Gera112020-04-14 04:55:15
JavaScript
Gera11, 2020-04-14 04:55:15

How to count li elements and add css attribute when a certain number of li elements is reached using jquery?

Imagine that we have a ul list inside which there are several li elements
How to make a script that adds the value overflow-y: scroll to the style attribute of the ul element; but only when there are more than 11 li elements in the ul list?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
A person from Kazakhstan, 2020-04-14
@Gera11

https://codepen.io/topicstarter/pen/ExVVVvJ - it seems so, but this is also done on css

D
drawnofmymind, 2020-04-14
@drawnofmymind

https://jsfiddle.net/u5powsc6/

S
sashabeep, 2020-04-14
@sashabeep

I would not recommend you use this method. Due to a difference in font rendering, for example, or several lines instead of one in a random list item, it may turn out that they will need to be scrolled much earlier than there are 11 of them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question