Why my javascript is not working? Please Help me

“Uncaught TypeError: searchBtn.addEventLister is not a function”
when i run my code then above error is show in console.My code is right but still this error is showing . please solve this problem. :sob:

<script>console.log('hello consoe');
    let searchBtn = document.querySelector('#search-btn');
    let searchBar = document.querySelector('.search-bar-container');
    /*
    searchBtn.onclick= function(){
       searchBar.classList.toggle('active');
    }
    */
    window.onscroll=() =>{
       searchBtn.classList.remove('fa-times'); 
       searchBar.classList.remove('active'); 
       menu.classList.remove('fa-times'); 
       navbar.classList.remove('active'); 
       loginForm.classList.remove('active');
    }
    
     searchBtn.addEventLister('click', ()=>{
     searchBtn.classList.toggle('fa-times'); 
      searchBar.classList.toggle('active'); 
    
     });
    
    
    let formBtn = document.querySelector('#login-btn');
    let loginForm = document.querySelector('.login-form-container');
    let formClose = document.querySelector('#form-close');
    
    formBtn.addEventListener('click',()=>{
       loginForm.classList.add('active');
    });
    formClose.addEventListener('click',()=>{
       loginForm.classList.remove('active');
    });
    
    
    let menu=document.querySelector('#menu-bar');
    let navbar=document.querySelector('.navbar');
    
    menu.addEventListener('click', ()=>{
       menu.classList.toggle('fa-times');
       navbar.classList.toggle('active');
    });
    
    
    let videoBtn=document.querySelectorAll('.vid-btn');
    videoBtn.forEach(btn=>{
       btn.addEventListener('click',()=>{
          document.querySelector('.controls .active').classList.remove('active');  
          btn.classList.add('active'); 
          let src = btn.getAttribute('data-src');
          document.querySelector('#video-slider').src=src;
       })
    });
    </script>




Capture

The method name is addEventListener, you have a typo. (missing n).
I suppose once fixed your error should go away.

Hope this helps :slight_smile:

EDIT:
A piece of advice from a fellow developer, always assume that the machine is always right, and you are always wrong.

So if the machine is telling you you have some error, work with the assumption that is more likely that you made a mistake, rather than the computer.
It will save some time and trouble :wink:

1 Like