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 7940755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:28:14+00:00 2026-06-03T23:28:14+00:00

I have 10 items in drop down and want to display only first 5

  • 0

I have 10 items in drop down and want to display only first 5 when i open the drop down list and rest of the items should remain in scroll.

I have the following code to control the size in JS.

$(function(){
  $("#myList").click(function(){
    $(this).attr('size', '5');
  });
});

Setting the following in HTML…

<select size="5">
  <option value=""></option>
  ...
</select>

will make the drop down to always appear with 5 items as default and browsers may handle this their own way so i thought of doing it via JS.

The problem with this is it open with 5 items but did not close automatically as what a normal drop down does, until page get refreshed (obviously). Please advise.

  • 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-06-03T23:28:15+00:00Added an answer on June 3, 2026 at 11:28 pm

    You could change the list so that it displays multiple items, and then only shows the selected when hover is removed:

    $(document).ready(function(){
    
    $("#mylist").hover(function(){
    
    $(this).attr('size', '5');
    },function(){
     $(this).removeAttr("size");   
    });
    
    });​
    

    — SEE DEMO —

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have drop down list with 5 items. I want to send the selected
I have a drop down menu with css file and i want to convert
I have created and html form which have a drop down list. This drop
I have a dictionary with a list of times I want to display in
I have two tables: I want to fill an ASP.NET server control drop down
i have 4 menu drop down list that i bind a click that calls
I have a dropdown list for items. What I want to do is get
I want to have the script display each item on a list of value
I have two drop down. SelCurrentManuf and selCurrentModel. I want the option in selCurrentModel
I have two drop down boxes in my program. When you select an item

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.