Quantcast
Channel: How to addEventListener to multiple elements in a single line - Stack Overflow
Viewing all articles
Browse latest Browse all 16

How to addEventListener to multiple elements in a single line

$
0
0

Example 1:

element1.addEventListener("input", function() {  // this function does stuff });

Example 2:

element1 && element2.addEventListener("input", function() {  // this function does stuff});

It might not be correct grammatically, but is there a way I can give two elements the same event listener at the same time (same line) instead of having to write them apart?


Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles





Latest Images