1. Blog
  2. Blogging Tips
  3. Technology

Create Beautiful <SELECT> Dropdown With EasyDropDown.js

<SELECT> is a HTML element that is used for selecting items using a drop-down list. It’s useful for when you have a very long list of items to select such as dates. Unfortunately, for those who want to create a fancy web page, the default<SELECT>in their web browser is not very user-friendly and doesn’t look great style-wise.

To style the element, CSS should be enough. But, well, it isn’t quite enough in terms of accessibility. Introducing EasyDropDown.js, a free jQuery plugin to cover up all those flaws.

EasyDropDown.js can easily style the old-fashioned select element in your web page with a lot of features. After the<SELECT>element has been applied with this plugin, it will obtain full keyboard control with textual search. This tool also provides an inner-scroll for items in long lists to limit the drop-down box size. Form and validation are available as well which helps with compatability.

Installation

To install EasyDropDown, firstly include jQuery library into your web page. Make sure to also include the javascript (get it here) like so:

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="js/jquery.easydropdown.js" type="text/javascript"></script> 

And its CSS file inside the head tag:

 <head> .. <link rel="stylesheet" type="text/css" href="themes/easydropdown.css"/> .. </head> 

If you’re using another theme, make sure to copy the files inside your web folder. Don’t worry as you don’t need to include them in the HTML to call them.

Styling The Select

When using EasyDropDown.js, you can build a customizable drop-down menu with a clean, semantic markup. The select elements can be styled within HTML only. You can disable the element, define a selected option or add a label easily.

To style it, you must firstly include a dropdown class into the tags. A label can be added by giving a label class inside the option. Here is the basic markup:

 <select class="dropdown"> <option value="" class="label">Setting</option> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> <option value="4">Option 4</option> <option value="5">Option 5</option> </select> 

That’s it, you don’t need any custom javascript to add. Now the lousy, old-fashioned<SELECT>has turned into a beautiful, fancy drop-down input.

If you want to add a pre-selected option simply give your drop-down with selected attribute. We recommend not using label with this setting altogether as the selected value will override the label.

 <select class="dropdown"> ... <option value="2" selected>Option 2</option> ... </select> 

You can also disable the drop-down using the disabled attribute like so:

 <select class="dropdown" disabled> ... </select> 

Ready To Use Themes

EasyDropDown.js comes with 2 more ready-to-use themes: Metro and Flat. To use the themes, you can utilize HTML5 data-attribute.

Inside the <SELECT> tag, call data-settings='{"wrapperClass":"theme-name"}' to apply another theme. Feel free to change the theme-name with the available theme names: metro or flat. Here is the example:

 <select class="dropdown" data-settings='{"wrapperClass":"metro"}'> ... </select> 

Beside wrapperClass, there are more settings you may add, see the documentation page for the details. If you’re cool with javascript code, you can see the tutorial there.



Contributor
No Comments
Comments to: Create Beautiful <SELECT> Dropdown With EasyDropDown.js

Recent Articles

Good Reads

Gemstones have been a source of fascination for centuries due to their unique colors, properties, and potential to influence emotions and energy. In addition to their aesthetic value, gemstones have been highly regarded by many cultures for their alleged ability to attract positive energy and prosperity. This article​ will discuss the ⁤arrangement of different gemstones […]

Worlwide

Overview VipsPM – Project Management Suite is a Powerful web-based Application. VipsPM is a perfect tool to fulfill all your project management needs like managing Projects, Tasks, Defects, Incidents, Timesheets, Meetings, Appointments, Files, Documents, Users, Clients, Departments, ToDos, Project Planning, Holidays and Reports. It has simple yet efficient layout will make managing projects easier than […]
Gemstones have been a source of fascination for centuries due to their unique colors, properties, and potential to influence emotions and energy. In addition to their aesthetic value, gemstones have been highly regarded by many cultures for their alleged ability to attract positive energy and prosperity. This article​ will discuss the ⁤arrangement of different gemstones […]
Bathroom lighting may not be a top priority for many homeowners in Singapore, but it can greatly impact our‌ experience in the ⁤space. To achieve optimal ⁤bathroom lighting, there are several factors to consider and tips to keep in mind when⁢ discussing lighting ‌concepts with your interior design‍ firm in Singapore. Why is Bathroom Lighting […]

Trending

Turquoise Jewelry is one of the ancient healing stones used for personal adornment and astrological benefits. The rare greenish blue-colored pectolite is celebrated for its enchanting powers among many crystal lovers. It is a hydrated phosphate of copper and aluminum that ranks 5 to 6 on the Mohs hardness scale. It is deemed a protective […]
24 March 2020, the evening when the Government of India ordered a nationwide lockdown for 21 days. Because the deadly Coronavirus crept into the world and turned it into a sinking ship, put unforeseen pressures on all of us with its destructive intentions. Soon after, it turned into a giant monster. Omicron, the new variant […]