Element retrieved in tagname becomes BODY instead of SELECT

Asked 2 years ago, Updated 2 years ago, 28 views

I got b for the pull-down (select tag), so I want it to be b=SELECT, but for some reason it might be b=BODY.

When I checked the activeElement specifications on the page below, I found the following:

Document.activeElement-Web API|MDN

The focus on which element depends on the current configuration of the platform and browser.For example, macOS systems typically do not focus on anything other than text input elements by default.

I don't use macOS, and b=BODY occurs in Windows and Chrome environments. Does anyone know why?

vara= document.activeElement;
varb = a.tagName.toUpperCase();

javascript html

2022-09-29 22:13

1 Answers

I can't read well from the question, but do you happen to confuse focus with select?
For example, if you press the Tab key to move focus, where does it jump? Do you want to return to the <select> element in Shift+Tab key? Does the key update the pull-down selection? Or does the screen scroll?

Why don't you check the behavior of focus on pages such as ?


2022-09-29 22:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.