JavaScript How to get the parameter to work inside a event function

As I want to unbind(off) the events I wrapped the code inside a function but as I need to see which key is pressed I need to get the event of the event(not sure how this is called.

// normal example

$('body').on('keydown',function( event ){
    if(event.keyCode == 37){
        // do something
    }
});

// my example

function keyDownHandler() {
     if(event.keyCode == 39) {
        // does not work
    }    
 }

$('body').on('keydown', keyDownHandler);
Answer:1

I am having to complete a exercise in JavaScript where I use RegExp. During testing, I stumbled across this returned array when I did a non global match. var first = "28".match(/[0-9]\s?/); console....

I am having to complete a exercise in JavaScript where I use RegExp. During testing, I stumbled across this returned array when I did a non global match. var first = "28".match(/[0-9]\s?/); console....

I want to rotate an image every time I click on it.. I've created a function to do this but the image only rotate the first time I click on it... Moreover, once the image rotate it change ...

I want to rotate an image every time I click on it.. I've created a function to do this but the image only rotate the first time I click on it... Moreover, once the image rotate it change ...

I am trying to call a JavaScript function from the onclick event of two different buttons. I have dug around and searched for like problems but have not found a solutions. When I click either button I ...

I am trying to call a JavaScript function from the onclick event of two different buttons. I have dug around and searched for like problems but have not found a solutions. When I click either button I ...

  1. unable to call function in ajax success
  2. unable to call function dllinstall
  3. unable to call javascript function from html
  4. unable to call the function dllinstall in the file browseui.dll
  5. unable to call javascript function from code behind
  6. powershell unable to call function
  7. unable to call javascript function
  8. unable to call the function dllinstall in the file webcheck.dll

So I'm trying to get the width of the element using jQuery. alert($("#theList li:eq(0)").offsetWidth); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></...

So I'm trying to get the width of the element using jQuery. alert($("#theList li:eq(0)").offsetWidth); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></...