0

I have click dropdown button using javascript, it's working on other browsers, except IE. I'm not quite sure what is the issue, I tried to use different syntax, but still not working, please help

document.querySelector('.language_toggle').addEventListener('click', function() {
    this.querySelector('.select_language').classList.toggle('open');
});

window.addEventListener('click', function(e) {
    const select = document.querySelectorAll('.select_language');

    for(var i = 0; i< select.length; i++) {
        if (!select[i].contains(e.target)) {
            select[i].classList.remove('open');
        }
    }

});
Udzzzz
  • 155
  • 9
  • 1
    Does this answer your question? [addEventListener in Internet Explorer](https://stackoverflow.com/questions/6927637/addeventlistener-in-internet-explorer) – Joseph Mar 31 '20 at 21:34
  • What version of IE are you testing in? And what do you mean by "not working"? is it throwing an error? – mcgraphix Mar 31 '20 at 21:59
  • @mcgraphix I'm testing IE11, not working the toggle click just not clickable or dropdown not showing up, it doesn't throw any error – Udzzzz Mar 31 '20 at 22:04
  • I'm not sure why someone closed this question. You may need to ask the question again with more details and say that it is IE11. My guess would be that, the issue is that the click even on your .language_toggle is bubbling up to the listener on the window and it is causing it to be closed. I'd put a breakpoint in that click listener on the window and see if remove('open') is being called. – mcgraphix Mar 31 '20 at 22:06

0 Answers0