Horje
removeeventlistener not working in class javascript Code Example
removeeventlistener not working in class javascript
'use strict'
class Mouser {
  constructor () {
    this.counter = 0
    this.clicked = function (event) {
      this.counter ++
      console.log('clicks:', this.counter)
      if (this.counter >= 10) this.remove()
    }
    // save the click handler so it can be used in multiple places
    this.clickHandler = this.clicked.bind(this);
    window.addEventListener('click', this.clickHandler)
  }

  remove () {
    console.log('Removing click listener') // this line runs ..
    window.removeEventListener('click', this.clickHandler)
  }
}

var mouse = new Mouser()




Javascript

Related
jquery visibility effects Code Example jquery visibility effects Code Example
discord js presence update Code Example discord js presence update Code Example
change class on resize window jquery Code Example change class on resize window jquery Code Example
replace function javascript recurrent Code Example replace function javascript recurrent Code Example
json token for .ini file Code Example json token for .ini file Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10