I am building a dynamic dropdown navigation.
In the dropdown there are multiple floating divs, but between each ‘row of items’ I have to add a horizontal divider. I can’t set a static width because the text-length of the items are dynamic and may not wrap.
So I am reading each container, reading all div items, I want to read the width of the items to add the divider but can’t manage it.
$('.muTopNavDropdown').each(function(i, e) {
var iWidth = 0;
$(this).find('.mainSubNavRowItem').each(function(ii, ee) {
if (iWidth > maxWidth)
alert('divide!');
alert($(ee).width() +'-'+ $(ee).offsetWidth +'-'+ $(ee).clientWidth);
iWidth += $(ee).width();
});
});
How do I read a floating div with no width value and dynamic content inside width?
Your code works for me. Are your divs visible?
If divs are set to display none jquery will not be able to return a width.