Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can multiple HTML elements receive focus at the same time?

I'm a coding a JavaScript reporting component, that requires multiple LI's i.e. lists to be selected collectively as a bunch with visual feedback.

I'm thinking of adapting the onfocus event. Is it possible for multiple HTML elements to receive focus at the same time?

Not inputs, but DIVs, so I don't need the cursor. I just want several DIVs to be "selected" separately from others, colored differently to simulate multiple item selection.

like image 652
Olaseni Avatar asked Jun 10 '10 17:06

Olaseni


People also ask

Which HTML elements can receive focus?

The following elements can receive focus: <a> tags with an href attribute. Form controls and buttons (unless the element is disabled) Any element with a tabindex .

Can multiple HTML elements share the same class?

The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.

What happens if two HTML elements have the same ID?

The id must be unique. There can be only one element in the document with the given id . If there are multiple elements with the same id , then the behavior of methods that use it is unpredictable, e.g. document. getElementById may return any of such elements at random.

How does focus work in HTML?

The HTMLElement. focus() method sets focus on the specified element, if it can be focused. The focused element is the element that will receive keyboard and similar events by default.


1 Answers

No, you can only focus on one element at a time.

like image 94
Babiker Avatar answered Oct 03 '22 01:10

Babiker