Skip to content

iainjmitchell/select-placeholder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

select-placeholder.js

A jQuery extension for providing placeholder text (AKA not selected text) on selects.

Dependencies

  • jQuery

Usage

Add a reference to jQuery and selectPlaceholder scripts into the HTML.

Within the HTML add a placeholder attribute to a select, the value will be the text displayed.

<select placeholder='Click something..'>
  <option>One</option>
  <option>Two</option>
</select>

Add into your javascript, the following...

$('select').selectPlaceholder();

That's it!

See demo.html for a working example.

How it works

A new option is inserted into the select, that contains the placeholder text. This is automatically selected, but cannot be reselected once a new option is choosen.

What still needs resolving :(

It would be better to NOT show hover effects and pointer when the cursor is on the placeholder option.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published