pass argument to event listener javascript
someObj.addEventListener('click', some_function(someVar) );
const some_function = (someVar) => {
return (e) => {
console.log(someVar)
console.log(e)
}
}var someEventHander=function(){
console.log(event,param1,param2);
}
//add listener
document.getElementById("someid").addEventListener('click',someEventHander.bind(event,param1,param2));var someEventHander=function(event,param1,param2){
console.log(event,param1,param2);
}
//add listener
document.getElementById("someid").addEventListener('click',someEventHander.bind(event,'param1','param2'), false);
Also in JavaScript:
- json search javascript
- javascript operator double not
- switch case in js
- javascript ceiling
- to capital case javascript
- javascript genreate number id
- how to create a server in node js
- javascript email validation
- position of the mouse cursor javascript
- nuxtjs http multiple proxy
- UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
- js create md5 hash
- make directive to return dropdown values angular
- flutter asset image not showing
- wait for ajax to finish
- change input placeholder text jquery
- data table in angular 8 from api
- remove duplicates from array
- how to remove last element in js
- libuv nodejs
- ajax laravel get values from form
- js toggle boolean
- render props
- copy a file and paste with fs