jQuery Accordion Focus

喜夏-厌秋 提交于 2019-12-06 11:05:12

You may be able to store the currently active element, and restore focus after the user clicks on the accordion header.

You can retrieve the currently focused element using the following code:

function onElementFocused(e)
{
    if (e && e.target)
        document.activeElement =
        e.target == document ? null : e.target;
} 

if (document.addEventListener)
    document.addEventListener("focus", onElementFocused, true); 

This will keep the currently focused element in the document.activeElement variable.

Using the 'changestart' and/or 'change event with the accordion, you can then restore the focus to the desired element every time the accordion changes.

You may need to add a clause or two to prevent the accordion header divs being set as the current active element in the above code, otherwise you'll just restore focus to the accordion header.

The above code is untested, as is the idea, but it should work I believe.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!