w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
adding listeners to buttons to execute functions

It's addEventListener, not addEventListeners (note the s).

Whenever you have foo(bar()), bar is called first and its return value is passed to foo. So in your case, you are calling clearOrSelectAll first and pass the return value to addEventListener.

However, addEventListener expects a function as argument and if clearOrSelectAll doesn't return a function, this won't work.


button.addEventListener("click", clearOrSelectAll);

and access the element the handler is bound to via this.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.