Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
How to make closure for custom select on a blank area or an element? - Q&A

How to make closure for custom select on a blank area or an element?

0 like 0 dislike
Good evening.

There is such code

sect3tab function() { if ($(window).width() <= 768) { $('.section-3 .mob-select-tab').on('click', function(){ $('.section-3 .info-wrap .left .ul').show(0); }); $('.section-3 .info-wrap .left .ul .li').on('click', mobLiFade); } else { $('.section-3 .info-wrap .left .ul').show(0); $('.section-3 .info-wrap .left .ul .li').off('click', mobLiFade); } } sect3tab();

It opens a tab (select)

I need to press on ".section-3 .mob-select-tab" how to open select and close ".section-3 .mob-select-tab".
And if what to prescribe to close the field, I will be eternally grateful)
asked by | 10 views

1 Answer

0 like 0 dislike
In order to help you - lay code of the demo on codepen or its equivalent, no one wants to guess on a coffee thick.

1) Opening and closing is usually done using .toggleClass('class').
For example - initially the menu is hidden via display: none, when clicks using toggleClass hung or removed the active class, in which the style is set to display: none;
Well or still it is possible to do check for display: none, and depending on result to do either .show() or .hide()
2) Hide on click outside area of the block is done as follows:
$(function ($) { $(document).mouseup(function (e) { const block = $(".walk"); // variable block is your block that is hidden/shown if (! && block.has( === 0) { block.removeClass('class'); // class which shows the unit, for example with display: block } }); });
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers


12.7k users

24,788 questions
46,220 answers
12,715 users