You can use these events provided by bootstrap for dropdown menus:
show.bs.dropdown: This event fires immediately after the show instance method is called.
shown .bs.dropdown: This event is fired when the popup window becomes visible to the user (it will wait for the CSS transition to complete).
hide.bs.dropdown: This event is fired immediately after calling the hide instance method.
hidden.bs.dropdown: This event is fired when the popup menu ends up hidden from the user (it will wait for the CSS transition to complete).
Using:
$('.dropdown').on('show.bs.dropdown', function () { // do something… // In your case var section = $('.av-nav .nav li a:hover'); var width = section.width(); if (width < 768){ section.addClass('nobg');} }) $('.dropdown').on('hide.bs.dropdown', function () { // do something… // In your case var section = $('.av-nav .nav li a:hover'); var width = section.width(); if (width < 768){ section.removeClass('nobg');} })
I think this will work, you may need to make some changes.
IBAD GORE
source share