Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The minimal changes version, but beware this only works on the *first* matching element
- var dropdownElement = document.getElementsByClassName(
- "filter-multi-select-dropdown filter-panel-item-dropdown dropdown-menu show"
- );
- document.addEventListener("click", (event) => {
- const firstMatchingElement = dropdownElement[0];
- if (event.target == firstMatchingElement) {
- firstMatchingElement.classList.remove("show");
- console.log("Clicked Outside");
- }
- });
- // Or alternatively, just check the target when the click happens
- // Note that unlike the above, this will work on *any* matching element
- document.addEventListener("click", (event) => {
- if (event.target.matches(".filter-multi-select-dropdown.filter-panel-item-dropdown.dropdown-menu.show")) {
- event.target.classList.remove("show");
- console.log("Clicked Outside");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement