What is addEventlistener, How can we use them in Javascript

I would like to see a basic example where it shows me how to use addEventListner and remove EventLister.

Add Comment
  • 1 Answer(s)
      <!doctype html>
      <meta charset="utf-8">
      <title>Event Listners</title>
      <div id="menu1" >Home</div>
      <div id="content1"> </div>
      <script type="text/javascript">
      var menu1 = document.getElementById('menu1');
      var content1 = document.getElementById('content1');
      menu1.addEventListener('click', clickfunciton);
      menu1.addEventListener('mouseover', mouseoverfunction);
      menu1.addEventListener('mouseout', mouseoutfunction);
      menu1.removeEventListener('mouseout', mouseoutfunction);
      function clickfunciton(){
      content1.innerHTML = " I am an Indian";
      Kid Answered on March 7, 2016.
      Add Comment

      Your Answer

      By posting your answer, you agree to the privacy policy and terms of service.