A
A
Aljo2021-06-22 10:17:52
JavaScript
Aljo, 2021-06-22 10:17:52

How to get the index of the last visible element in a block with overflow hidden?

Hello!

There is a block that can be collapsed with a button. So, how to get the index of the last visible element when the block is collapsed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aljo, 2021-08-26
@aljo222

Did it like this:

if (container.hasClass('hidden')) {
      var containerWidth = container.outerWidth();
      var totalWidth = 0;
      var childrens = container.children();
      var i = 0;
      while (totalWidth < 300) {
        totalWidth += childrens.eq(i).outerWidth(true);
        i++;
      }      
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question