It works like this:
- Takes all attributes of a
<select>
tag and replaces it with adiv
with the same attributes (classes, id's etc). - The
<div>
is given certain behaviors to make it act almost like a normal select box. - In the div, we add a
<input type="hidden">
so that a name/value will get submitted along with the form as expected. - Unlike other select box replacement plugins I've seen, this one is meant to be styled entirely in css. The only css property that the plugin sets is the
overflow
property, to control the showing and hiding of the options. This gives you complete freedom to style it however you want.
Basic use:
$('#my_select_box').dd();
- You'll also need some basic styles. Or it won't appear to work. Grab what you need from styles.css as a starting point and then tweak it to your heart's desire.
Shortcomings:
- No keyboard support, yet.
- No way to tab to it, yet.
Advanced use:
-
It supports
onChange
events by passing a function to the plugin like this:$('#test1').dd({ change_callback: function() {alert(this);} });