jQuery figuring out if parent has lost 'focus'

后端 未结 7 1908
小鲜肉
小鲜肉 2020-12-16 05:39

I\'m stuck on figuring out the logic to make a drop down menu keyboard accessible.

The HTML is structured as such (extra class names used for clarity):



        
7条回答
  •  隐瞒了意图╮
    2020-12-16 06:27

    How about if you do the following:

    $('#link_A_id, #link_A_id > *').focusout(function () {
        if ($(document.activeElement).closest('#link_A_id').length == 0)
            //focus is out of link A and it's children
    });
    

提交回复
热议问题