Reputation: 109
Why this code not work in Firefox? I want to make the switch pictures in gallery on keyup event. I had read similar problems and answers, but no one help me. jQuery 1.4.4 My code:
$('body').live('keyup',function(e){
if(e.keyCode == 37) {
$('.daPrev').click()
}
else if(e.keyCode == 39) {
$('.daNext').click()
}
})
When i press, in console:
ReferenceError: event is not defined
Upvotes: 0
Views: 1092
Reputation: 109
Problem has been solved using jQuery migrate. Thank's you all
Upvotes: 0
Reputation: 2315
your code does not seem to caus the reference error. check other functions triggered, when you press.
i made a fiddle, tried in FF and console will log "37"
$('body').live('keyup',function(e){
console.log('37')
if(e.keyCode == 37) {
$('.daPrev').click()
}
else if(e.keyCode == 39) {
$('.daNext').click()
}
})
Upvotes: 0
Reputation: 31
I don't see any variable called event in your code, and it looks valid. However, some things you can try:
.delegate:
$.delegate(selector, eventType, handler);
I.e.
$.delegate("div", "keyup", function(e) {...});
Upvotes: 1