Инструменты разработки

How to detect click outside a container in jQuery?

How to detect click outside a container in jQuery?
javascript
1234567
$(document).on("click", function (event) {
  if (!$(event.target).closest(".dropdown").length) {
    $(".dropdown-menu").slideUp("fast");
    // Showing the hint message
    $(".hint").html("A click <b>outside</b> the dropdown is detected.");
  }
});

Понравилась статья?

Подпишитесь на нашу рассылку, чтобы получать новые статьи и обновления