O
O
offsiderst2021-06-09 11:16:02
JavaScript
offsiderst, 2021-06-09 11:16:02

How to hide blocks outside of a click?

with this markup (that is, without changing the markup)

clicked on the active language - the submenu opens

clicked outside the active language - the submenu is hidden
https://jsfiddle.net/Lmr1kp6f/2/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2021-06-09
@offsiderst

$('.language-chooser li').on('click', function(evt) {
  evt.stopPropagation();
  evt.preventDefault();
  $('.language-chooser li').show(); // show all languages
});

$(document).on('click', function(evt) {
  $('.language-chooser li:not(.active)').hide(); // hide inactive languages
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question