I have a horizontal menu with overflow: a hidden application to it.
The menu is managed by CMS, so sometimes it does not overflow, but when it overflows, I want to find the last visible li element and insert the ul dropdown link with overflowed menu items. The problem I am facing is to select the last visible person (to insert the HTML in front of her) as the elements hidden by the overflow: the hidden ones still seem visible.
My code so far:
$(window).load( function () { var totalWidth = 0; var menu = $('.nav .menu ul'); var menuWidth = menu.innerWidth(); menu.find('li').each(function() { totalWidth += $(this).innerWidth() + 30;
The variable num_li returns the total number of li elements, not just those visible to the person viewing the page!
source share