I’m trying to perform a keypress event the divs inside the bus_lines div.
$('#bus_lines').keypress(function(e){
var box = $(this).closest("div:hidden").attr("id");
console.log(box);
});
Here’s what it looks like in firebug:

It only works on the parent div which is the one with the bus_lines id. If I try to perform keypress events inside of fs_buslines or fs_bustax its not working. I need to know the closest div where the keypress is performed. Basically I’m trying to perform button click events using keyboard shortcuts.
closestsearches through an element’s ancestors. It looks like you’re looking for the first descendant of the current element that matches a selector. As a result, you wantfind