Why not just get the arguments from the target attribute of the event?
Example:
const someInput = document.querySelector('button');
someInput.addEventListener('click', myFunc, false);
someInput.myParam = 'This is my parameter';
function myFunc(evt)
{
window.alert(evt.currentTarget.myParam);
}
<button class="input">Show parameter</button>
JavaScript is a prototype-oriented language, remember!
Related Contents:
- For loop for HTMLCollection elements
- Why does jQuery or a DOM method such as getElementById not find the element?
- onKeyPress Vs. onKeyUp and onKeyDown
- Do DOM tree elements with IDs become global properties?
- Converting HTML string into DOM elements?
- How to check in Javascript if one element is contained within another
- Cannot read property ‘addEventListener’ of null
- How do I replace text inside a div element?
- How to get element by class name? [duplicate]
- Count immediate child div elements using jQuery
- HTML “overlay” which allows clicks to fall through to elements behind it [duplicate]
- Difference between “change” and “input” event for an `input` element
- Best Practice: Access form elements by HTML id or name attribute?
- Event when window.location.href changes
- Get elements by attribute when querySelectorAll is not available without using libraries?
- Is innerHTML asynchronous?
- Is there ‘element rendered’ event?
- jQuery Force set src attribute for iframe
- Is there any way of passing additional data via custom events?
- document.querySelector multiple data-attributes in one element
- How can I get access to a Highcharts chart through a DOM-Container?
- DOM element to corresponding vue.js component
- Find DOM element by ID when ID contains square brackets?
- How to check if DOM is ready without a framework?
- MSIE and addEventListener Problem in Javascript?
- How to properly unload/destroy a VIDEO element
- Correct usage of addEventListener() / attachEvent()?
- How can I remove a child node in HTML using JavaScript?
- How to continue event propagation after cancelling?
- How to copy a DOM node with event listeners?
- Replace HTML page with contents retrieved via AJAX
- JavaScript – Get all but last item in array
- How do I programmatically click on an element in JavaScript?
- matchMedia().addListener marked as deprecated, addEventListener equivalent?
- createElement vs. createElementNS
- Adding text to an existing text element in JavaScript via DOM
- Converting em to px in Javascript (and getting default font size)
- Removing an anonymous event listener
- How to iterate through all attributes in an HTML element?
- Is it possible to programmatically catch all events on the page in the browser?
- Code inside DOMContentLoaded event not working
- Get the name (type) of the event that was fired (triggered)
- How to get coordinates of an svg element?
- Getting width & height of an image with filereader
- How to serialize DOM node to JSON even if there are circular references?
- call javascript function from anchor html tag
- How to remove DOM elements without memory leaks?
- Images failing to load in IE with DOM: 7009 error (unable to decode) in console
- Does the onchange event propagate?
- Are event handlers in JavaScript called in order?