Skip to content

Repository files navigation

#jQuery Selectric icon

jQuery Selectric is a jQuery plugin designed to help at stylizing and manipulating HTML selects.

  • Keyboard navigation (Up/Down/Left/Right/Word search)
  • Easily customizable
  • Pretty lightweight (3,5KB minified and less than 2KB minified/gzip)
  • Options box always stay visible
  • Doesn't rely on external libraries (besides jQuery)
  • Word search works with western latin characters set (e.g.: á, ñ, ç...)

###Demo

##How to use:

Make sure to include jQuery in your page:

<scriptsrc="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Include jQuery Selectric:

<scriptsrc="js/jquery.selectric.min.js"></script>

Put styles in your CSS and change it to your taste :D

/*======================================================================	Selectric======================================================================*/
.selectricWrapper { position: relative; margin:0010px; width:300px; cursor: pointer; }
.selectricDisabled { filter:alpha(opacity=50); opacity:0.5; cursor: default; -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
.selectricOpen { z-index:9999; }
.selectricHideSelect { position: relative; overflow: hidden; }
.selectricHideSelectselect { position: absolute; left:-100%; }
.selectric { border:1px solid #DDD; background:#F8F8F8; position: relative; border-radius:2px; }
.selectricOpen .selectric { border-color:#CCC; background:#F0F0F0; z-index:9999; }
.selectric .label { display: block; white-space: nowrap; overflow: hidden; margin:030px00; padding:6px; font-size:12px; line-height:1.5; color:#444; }
.selectric .button { position: absolute; right:0; top:0; height:30px; width:30px; color:#BBB; text-align: center; font: normal 18px/30px sans-serif; }
.selectricHover .selectric { border-color:#CCC; }
.selectricHover .selectric .button { color:#888; }
.selectricTempShow { position: absolute !important; visibility: hidden !important; display: block !important; }
/* Items box */
.selectricItems { display: none; position: absolute; overflow: auto; top:100%; left:0; background:#F9F9F9; border:1px solid #CCC; z-index:9998; box-shadow:0010px-6px; /* margin: -1px 0; */ }
.selectricItemsul,
.selectricItemsli { list-style: none; padding:0; margin:0; min-height:20px; line-height:20px; font-size:12px; }
.selectricOpen .selectricItems { display: block; }
.selectricItemsli { padding:5px; cursor: pointer; display: block; border-bottom:1px solid #EEE; color:#666; border-top:1px solid #FFF; }
.selectricItemsli.selected { background:#EFEFEF; color:#444; border-top-color:#E0E0E0; }
.selectricItemsli:hover { background:#F0F0F0; color:#444; }
.selectricItemsli.disabled { background:#F5F5F5; color:#BBB; border-top-color:#FAFAFA; }

Initialize jQuery Selectric:

<script>$(function(){$('select').selectric();});</script>

##Options:

OptionDefaultTypeDescription
onOpenfunction() {}FunctionFunction called when select options is opened
onClosefunction() {}FunctionFunction called when select options is closed
maxHeight300IntegerMaximum height options box can be
keySearchTimeout500IntegerAfter this time without pressing any key, the search string is reseted
arrowButtonMarkup<b class="button">&#9662;</b>String [HTML]Markup for open options button
disableOnMobiletrueBooleanInitialize plugin on mobile browsers
border1IntegerOptions box border thickness
openOnHoverfalseBooleanOpen select box on hover, instead of click
expandToItemTextfalseBooleanExpand options box past wrapper

##Public methods:

$('select').selectric('refresh');// Reconstruct the instance of plugin$('select').selectric('destroy');// Destroy Selectric and go back to normal$('select').selectric('open');// Open options$('select').selectric('close');// Close options

##Browser support:

  • Firefox
  • Chrome
  • Safari
  • Internet Explorer 7+
  • Opera

About

jQuery plugin for easy manipulation and customization of HTML selects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors