Passing Parameters to KeyDown
问题 How can you pass parameters into the keydown method from jquery because whenever I use a variable defined elsewhere it returns undefined. I assume its because the #target is window and therefore its not in the scope but even then I have trouble getting it to compare the key.which() with an outside parameter and then assigning it to another property. Example: var a = 38; var b = 0; $(document).keydown(function(e){ var key = e.which; if (a==key) b=key; }); console.log(a+""+b); Whenever I try to