We have 2 level menu
Block1 and Block2 in the screenshot http://prntscr.com/kp2tvi are independent, Block2 is outside Block1.
Code like this:
$('.bl-1').hover(function() { var childBlock = $('[data-parent="' + $(this).data('children') + '"]'); $(this).addClass('hover'); $(childBlock).css({ 'display': 'block' }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="bl-1" data-children="vanny">Ванны</div> <div class="bl-2" data-parent="vanny" style="display: none"> <ul> <li>Акриловые</li> ... </ul> </div> Those. for a hover on .bl-1, it is assigned a class .hover and the display property of .bl-2 changes
I can not figure out how to properly close these blocks. They must be closed if the cursor leaves .bl-1 in the right / left / upward directions (see screenshot), or if the cursor leaves .bl-2.
A little confused explained, but I hope that you can understand the essence of the issue.