Advertisement
arie_cristianD

language swicher dwopdown script

Oct 24th, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.addEventListener('DOMContentLoaded', function() {
  2.     var dropdownButtons = document.querySelectorAll('.jnews-lang-custom-dropdown-btn');
  3.     dropdownButtons.forEach(function(button) {
  4.         var dropdownContent = button.nextElementSibling;
  5.         button.addEventListener('click', function() {
  6.             dropdownContent.classList.toggle('show');
  7.         });
  8.     });
  9.     window.addEventListener('click', function(event) {
  10.         dropdownButtons.forEach(function(button) {
  11.             var dropdownContent = button.nextElementSibling;
  12.  
  13.             if (!button.contains(event.target) && !dropdownContent.contains(event.target)) {
  14.                 dropdownContent.classList.remove('show');
  15.             }
  16.         });
  17.     });
  18. });
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement