Which HTML elements can receive focus?

后端 未结 5 816
死守一世寂寞
死守一世寂寞 2020-11-22 00:20

I\'m looking for a definitive list of HTML elements which are allowed to take focus, i.e. which elements will be put into focus when focus() is called on them?<

5条回答
  •  你的背包
    2020-11-22 01:13

    Maybe this one can help:

    function focus(el){
    	el.focus();
    	return el==document.activeElement;
    }

    return value: true = success, false = failed

    Reff: https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/activeElement https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus

提交回复
热议问题