File tree Expand file tree Collapse file tree 1 file changed +27
-20
lines changed Expand file tree Collapse file tree 1 file changed +27
-20
lines changed Original file line number Diff line number Diff line change 22< head >
33 < style >
44
5- . my- dropdown {
6- width : 100 px ;
7- height : 20 px ;
5+ /* hide the dropdown options container initially */
6+ select {
7+ display : none ;
88 }
99
10- .my-dropdown .my-dropdown-options-container-active {
11-
10+ .my-dropdown {
11+ width : 200px ;
12+ height : 20px ;
13+ position : relative;
14+ cursor : pointer;
1215 }
1316
14- /* hide the dropdown options container initially */
1517 .my-dropdown-options-container {
18+ position : absolute;
19+ top : 0 ;
20+ left : 0 ;
1621 display : none;
22+ background : grey;
23+ width : 100% ;
24+ height : auto;
1725 }
1826
1927 /* when the dropdown options container is shown */
20- .my-dropdown .my-dropdown-options-container-active .my-dropdown-options-container {
21- width : 100px ;
22- height : auto;
23- background : grey;
28+ .my-dropdown-options-container-active .my-dropdown-options-container {
29+ display : block;
30+ }
31+
32+ .dropdown-option {
33+ box-sizing : border-box;
34+ padding : 6px 0 ;
35+ border-bottom : 1px solid black;
2436 }
2537
2638 </ style >
3345 < option value ="DC "> Washington, DC</ option >
3446</ select >
3547
36- < script src ="path/to /form.js "> </ script >
48+ < script src ="../dist /form.js "> </ script >
3749
3850< script >
3951 var dropdown = new Form . Dropdown ( {
40- el : document . getElementsByClassName ( 'select' ) [ 0 ] ,
52+ el : document . getElementsByTagName ( 'select' ) [ 0 ] ,
4153 containerClass : 'my-dropdown' ,
4254 optionsContainerClass : 'my-dropdown-options-container' ,
4355 optionsContainerActiveClass : 'my-dropdown-options-container-active'
4456 } ) ;
4557
46- // set value
47- dropdown . setValue ( 'MD' ) ;
48-
49- //get current value
50- dropdown . getValue ( ) ;
58+ // set value to MD on load
59+ dropdown . setValue ( 'VA' ) ;
5160
52- // destroy when done
53- dropdown . destroy ( ) ;
5461</ script >
5562
5663</ body >
57- </ html >
64+ </ html >
You can’t perform that action at this time.
0 commit comments