I would like to attach a focus event listener to the first element and when it fires, then second element border will be red.
The first element is inside of the second element.
The problem: I cannot attach the event listener to the first element, because it does not exist when javascript / jQuery executes.
Why?: the first element loads long after the page loads because I use long poll on my website.
Because of this, I tried to use jQuery .ready
method, but it did not work, because .ready
fires too early. The first element loads long after .ready
fires (the javascript / jQuery executes still too fast).
After this I tried to use CSS (CSS does not cares if elements exists or not, it works when the element loads after CSS loads), but I found only this: How to affect other elements when one element is hovered
In the previous page the solution can be made with CSS only when second element is inside the first element or they are siblings. In my case the second element is outside of the first element, so I cannot use CSS. What do you think?