I have to catch the event.target.value
in a handler. But my function takes another parameter along with event
parameter. That's why it doesn't get the event.target
. It returns undefined
. So how can I find event.target
if I have another parameter along with?
function a(e, b) {
console.log(e.target.value);
return e.target.value + b;
}
var input = document.querySelector('#input');
input.addEventListener('click', function() {
a(4);
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input id="input" type="submit" value="5">
</body>
</html>