I have the following function which fires when clicked but how would I also make it fire on enter without creating a new function? (if possible).
$("#jump_menu select option").click(function(){
var hash = $(this).val();
var target_offset = $(hash).offset();
$('html, body').animate({scrollTop:target_offset.top}, 500);
})
Try binding to
…instead.
Alternatively just move it to a standalone function and bind to what you need:
You may need to save and compare event timestamps though to ensure you don’t call your handler twice for a single selection.