0

I was checking some code and found an issue that on key press a JS event is called with no parameter passed and he consoles the event. The event object gets displayed in chrome but not on Mozilla.

Please find the sample code below: HTML

<input type="text" onkeypress="func()"/>

JS

function func(){
 console.log(event);
}

The above works fine in chromium but not on Mozilla.

Web_Designer
  • 72,308
  • 93
  • 206
  • 262
narengs7
  • 67
  • 1
  • 9

1 Answers1

0

I've come across situations like this as well. Passing the event as a param to the function works, both in Chrome and in Firefox.

Maybe this will help.

How to pass event as argument to an inline event handler in JavaScript?

Community
  • 1
  • 1
A.Perera
  • 7
  • 3