I have a navigation bar(topmenu) inside a div. I have to hide the rest of the menu elements if the width of the menu is greater than that of the outer div. Unfortunately I cant use overflow:hidden
for the div .So I use .outerWidth()
function to calculate the total width of the div and the width of each elment(li), and hide the overflow elements. So my problem is its works fine in firefox(19.0),IE(8)!, but not in chrome. In chrome all elements are hidden. The problem resolves when i change
$(document).ready(function() {});
to $(window).load(function() {});
But then, The total ul is shown for a fraction of second, then it get hidden(IE,FF it still works fine). Is there any better solution for this? Or any different logic.
Sample
<div style="width:300px;" >
<ul id="menu1">
<li class="noChild "><a href="#" >3 Option</a></li>
<li class="noChild"><a href="#" >2 Option</a></li>
<li class="noChild "><a href="#" >1 Option</a></li>
</ul>
</div >