1
Hello, good afternoon :) I have the following HTML code:
<section class="sectionQuemSomos">
<a class="iconQuemSomos" id="QuemSomos">
<img class="img-fluid" style="height: 80px" src="assets/img/icos/Icone_Quemsomos.png">
</a>
</section>
and the following JS code:
$(document).ready(function() {
"use strict";
var quemSomos = document.getElementById("QuemSomos");
$(document).addEventListener('focus', function(){
if (quemSomos === document.activeElement){
alert("efds");
}
});
});
As simple as it sounds, I’m not getting this if check back true and into your code block. I click on the tag to give it the focus but no Lert is displayed, so I know it’s not working that check.
I am trying to implement this eventListener so that this verification can take place after the document is ready.
Thank you for your attention!
Try it like this:
if ($(quemSomos).is(":focus")){
– Sam
didn’t work out =\
– Mikhael Araujo
You want to check if you focus on page loading. This doesn’t work. You have to use some event.
– Sam
yeah. I’m thinking about it right now... you know how I could use this event?
– Mikhael Araujo
well, now you’ve changed the question and the answers have become meaningless, you should put a note saying that you edited, because you put the suggestion of my answer, there it seems that I answered without reading your question :P
– Ricardo Pontual
Sorry! I don’t have much custom with this "forum" . hauhusa my fault!
– Mikhael Araujo