I had a problem with some jquery and I was wondering if you can help.
I have a menu with a drop-down list and I would like to change the position of the drop-down list depending on which element of the list it is. And how wide the drop-down is, what I still have ...
$(document).ready(function() { var subnavWidth = $('.sub-nav-wrapper').width(); if(subnavWidth > 900) { $('.sub-nav-wrapper').addClass('two-column-offers'); } else if (subnavWidth > 800) { $('.sub-nav-wrapper').addClass('one-column-offers'); } else if(subnavWidth > 600) { $('.sub-nav-wrapper').addClass('offers'); } else if(subnavWidth > 500) { $('.sub-nav-wrapper').addClass('two-column'); } else if(subnavWidth > 300) { $('.sub-nav-wrapper').addClass('one-column'); } });
but only takes into account the first element of the list in the menu and applies the corresponding class to each of the auxiliary navigations. I want it to check the width for each sub-navigation not only the first one, and then apply the class to this particular sub.
Hope this makes sense.
source share