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? - bug-code.com Q&A

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

0 like 0 dislike
10 views
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)
5bd890b42909d460575184.png5bd890d21c4bd792683383.png


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.is(e.target) && block.has(e.target).length === 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

0 comments

12.7k users

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