I
I
Igor2016-03-20 16:25:47
JavaScript
Igor, 2016-03-20 16:25:47

How to hang addEventListener( "focus ") on firefox focus event?

Tried that, but it didn't work

someDivOne=document.all("someDivOne");

someDivOne.addEventListener("focus",function(event){
    event.target.style.background = "pink";  
},true);

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Azim Kurt, 2016-03-20
@IgorBee

Specify the tabindex ="1" attribute for the div.
Example

D
Dima Pautov, 2016-03-20
@bootd

This only works in IE as far as I can remember!
document.all is Microsoft's proprietary extension to the W3C standard.
Use getElementById()

A
Anton Ratnik, 2016-03-20
@Ratnick

focus - event for inputs and text fields, and for hover - mouseover
Read all about the search for elements and events - so that questions disappear

F
funtik52, 2016-03-20
@funtik52

If you need to hang the "focus" event handler on the entire page, try this:

document.body.addEventListener("focus", function(event){
 //Твоя функция
},true);

I guess that when "tabbing" the background will change. Now I'll try it myself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question