469,909 Members | 1,686 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

How to check if a div element is focused

Hello,

I am searching for a way to check if a div is in focus or not (something like the focused property of the input elements).


The reason is that I have created the following scrollable select area using div:

<div id="scrolldiv" style="border : solid 2px grey; padding:4px; width:300px; height:180px; overflow:auto;">
<div onclick='highlightOption(this.id)'></div>
...
</div>

Everything works fine and I can now put anything I want in the separate options (unlike the standard select form). What I have lost is the ability to move up/down the select area with up/down key arrows.

I know how to capture the keyup/keydown events but I don't know how to check if the scrolldiv is in focus in order to move up/down the selection before passing the event to the scrolling function.
Oct 16 '10 #1
0 1126

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

22 posts views Thread by DJ WIce | last post: by
1 post views Thread by Michael A. Covington | last post: by
5 posts views Thread by orahm | last post: by
8 posts views Thread by Boni | last post: by
2 posts views Thread by Janis Papanagnou | last post: by
reply views Thread by =?Utf-8?B?cGF0cmlja2RyZA==?= | last post: by
2 posts views Thread by jodleren | last post: by
7 posts views Thread by John Koleszar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.