I have try build multi dropdown on hover. But, sub dropdown menu is going out of browser screen. I want to reverse dropdown menu position when which is go out of browser screen.
Here, I have try to use following jQuery for add dynamic class when which dropdown go out of screen. But, It does not work properly. It does addClass in every dropdown menu instead of go off browser screen.
Should be apply only for Which are going out of the browser screen.
I want to reverse each Drop down Which are going out of the browser screen.
What could be wrong here?
$('#menu .dropdown-menu').each(function() {
var menu = $('#menu').offset();
var dropdown = $(this).parent().offset();
var docW = $("#menu").width();
var i = (dropdown.left + $(this).width()) > (docW);
if (!i) {
$(this).addClass('dropdown-reverse');
} else {
$(this).removeClass('dropdown-reverse');
}
});