Note that there are some explanatory texts on larger screens.

plurals
  1. POCan there be or is there a javascript addEventListener multiple arguments on single line helper function?
    text
    copied!<p>can there be or is there something already, that can allow me to add multiple event listeners with multiple functions for different elements...on a single line? Maybe an example will help me explain...</p> <p>I am coming across situations like this in my code:</p> <pre><code>inputUrl.addEventListener ('keydown', saveOptions); inputUrl.addEventListener ('keydown', resizeInput); inputUrl.addEventListener ('keyup', saveOptions); inputUrl.addEventListener ('keyup', resizeInput); inputUrl.addEventListener ('click', saveOptions); inputUrl.addEventListener ('click', resizeInput); inputDirectory.addEventListener ('keydown', saveOptions); inputDirectory.addEventListener ('keydown', resizeInput); inputDirectory.addEventListener ('keyup', saveOptions); inputDirectory.addEventListener ('keyup', resizeInput); inputDirectory.addEventListener ('click', saveOptions); inputDirectory.addEventListener ('click', resizeInput); </code></pre> <p>It seems it might be VERY nice to have something along the way of this to shorten the code!</p> <pre><code>makeEvents("inputUrl,inputDirectory|saveOptions,resizeInput|keydown,keyup,click") </code></pre> <p>I hope this makes sense. Any ideas? If something like this already exists I would like to know. Otherwise maybe I could make a helper function (called makeEvents, or something), that would split the string, and for each element, then each function, attach each event???</p> <p>I know my existing code logic doesn't make perfect sense at the moment, but I am mostly curious if this could be easily done or already exists. Thanks! the_maxx</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload