Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:42:06+00:00 2026-05-24T02:42:06+00:00

i would like to have a DIV list on which the user can navigate

  • 0

i would like to have a DIV list on which the user can navigate by pressing up/down cursor keys and getting event when he changes the current DIV, as it happens in Google Instant results. Do you know if there is a jQuery/JS component to achieve it or any suggestions on the components to use.

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:42:07+00:00Added an answer on May 24, 2026 at 2:42 am

    Edit

    I changed it to use mouseover for highlighting the divs and setting the content of the input on click and the arrow keys. I think this is more similar to Google’s which is what you wanted.

    End Edit

    I just wrote this for you. I hope you’re able to use it: http://jsfiddle.net/Paulpro/evBkC/8/
    It should be easy to modify the css to style it the way you want from there. It highlights a div onclick and detects the up and down arrow keys if the input field has focus. It keeps track of the selectedDiv’s index in a variable called selectedDiv so you can use it if you want. It should be fully cross-browser as far back as IE 5.5 at least and all the other major browsers.

    HTML:

    <div id="nav">
        <input type="text" />
        <div>Line 1</div>
        <div>Line 2</div>
        <div>Line 3</div>
        <div>Line 4</div>
        <div>Line 5</div>
        <div>Line 6</div>
    </div>
    

    CSS:

    #nav, #nav input{
      width: 300px; 
    }
    
    #nav div{
      width: 150px;    
      margin-left: 75px;
      border-right: 1px solid #000;
      border-bottom: 1px solid #000;
      border-left: 1px solid #000;
      cursor: pointer;
    }
    

    Javascript:

    var divs = document.getElementById('nav').getElementsByTagName('div'),
    selectedDiv = 0,
    i;
    
    for(i = 0; i < divs.length; i++){
        divs[i].onmouseover = (function(i){
           return function(){
               divs[selectedDiv].style.backgroundColor = '';
               selectedDiv = i;
               divs[selectedDiv].style.backgroundColor = '#68F';
           }
        })(i);
    
        divs[i].onclick = function(){
            document.getElementById('nav').
              getElementsByTagName('input')[0].focus();
            document.getElementById('nav').
              getElementsByTagName('input')[0].value = 
                (this.innerText || this.textContent);
        };
    }
    
    divs[selectedDiv].style.backgroundColor = '#68F';
    
    document.getElementById('nav').
      getElementsByTagName('input')[0].onkeydown = function(e){
         var x = 0;
         if(e.keyCode == 38)
             x = -1;
         else if(e.keyCode == 40)
             x = 1;
         else
             return;
         divs[selectedDiv].style.backgroundColor = '';
         selectedDiv = ((selectedDiv+x)%divs.length);
         selectedDiv = selectedDiv < 0 ? 
           divs.length+selectedDiv : selectedDiv;
         document.getElementById('nav').
           getElementsByTagName('input')[0].value = 
             (divs[selectedDiv].innerText || divs[selectedDiv].textContent);
         divs[selectedDiv].style.backgroundColor = '#68F';
    };
    
    document.getElementById('nav').
      getElementsByTagName('input')[0].focus();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of div names, the div of which I would like
I would like to have a div which changes its content on the page
I have a listview which I would like to fill with self created user
We have a div where we would like the width to be dynamic in
I have a div that I would like to reposition each time the page
I have a div element in an HTML document. I would like to extract
I have two divs. I would like to move/populate the text from div id
I have the following HTML: <div id=mydiv> </div> I would like to load content
I have a layout similar to this: <div id=...><img src=...></div> and would like to
I have a list of items which contains a div and a link e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.