473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 1219

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

Similar topics

22
by: DJ WIce | last post by:
Hi, I'm looking for a script to get the hi-est z-index on a page. I want my javascript menu to be always on top of the page (moves along on top when you scroll down). Does anyone know how to...
3
by: Dai Ba Wong | last post by:
Hi: Currently I am having a problem with my webpage. My page consist of two frames, one consist of input text field and the other contains link for different pop-up windows. The problem...
1
by: Michael A. Covington | last post by:
Why is it that, if there is a combo box on the main form, it gets the focus initially, regardless of which other element we have set the focus to?
5
by: orahm | last post by:
I have 2 textboxes and one button and I don't know why my code doesn't work. All I'm trying to do is write a number 1 into the textbox with the focus. so if the user puts the cursor in textBox1 and...
8
by: Boni | last post by:
Dear all, is it possible to get a name of control on the form, which is currently in focus. Thanks, Boni
2
by: Janis Papanagnou | last post by:
I want to use the 'cloneNode(true)' method to duplicate table rows with all its subnodes. Cloning the complete tree is very handy but I must be cautious because of the unique IDs and names that...
0
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I have these three questions and though to post them in a single thread: 1) I have created a textarea: <textarea id="txtCards" cols="50" rows="15" runat="server" wrap="virtual"...
2
by: jodleren | last post by:
Hi I want to open a window using JS, when a button is pressed. In the new window I'd like to check for which button was pressed. For cetain reasons, I'd like not to have that in the URL. What...
1
by: nayana4u | last post by:
I want to take the id of the focused element in the page by javascript. but with my situation i cant use the onFouse() method of each element to call other javascript element. simply without...
7
by: John Koleszar | last post by:
Hi all, I'm porting some code that provides compile-time assertions from one compiler to another and ran across what I believe to be compliant code that won't compile using the new compiler. Not...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.