This time I will share jQuery Plugin and tutorial about jQuery Plugin For Custom HTML Select Element – Gorilla Dropdown, hope it will help you in programming stack.
Gorilla Dropdown is a jQuery plugin that converts the normal html <select>
element into an easy-to-style dropdown list with custom images and descriptions.
How to use it:
1. Include the jQuery Gorilla Dropdown plugin’s files on the web page which has jQuery JavaScript library installed.
1 |
< link rel = "stylesheet" href = "jquery.gorilla-dropdown.css" > |
2 |
< script src = "//code.jquery.com/jquery-3.2.1.slim.min.js" ></ script > |
3 |
< script src = "jquery.gorilla-dropdown.js" ></ script > |
2. Initialize the plugin on the target <select>
element and done.
- data-imgsrc: image path
- data-description: more description
1 |
<select id= "mySelect" class= "some-class" > |
2 |
<option value= "saab" data-imgsrc= "Saab.jpg" data-description= "Description about Saab" >Saab</option> |
3 |
<option value= "mercedes" data-imgsrc= "Mercedes.jpg" data-description= "Description about Mercedes" >Mercedes</option> |
1 |
$( "#mySelect" ).gorillaDropdown(Options); |
3. That’s it. By default, this plugin will convert the <select>
element into the following (note this does not include css styling):
01 |
< div id = "mySelect" class = "some-class gorilla-dropdown" > |
03 |
< div class = "container" > |
07 |
< span class = "arrow" >▼</ span > |
14 |
< img class = "image" src = "Saab.jpg" > |
18 |
< div class = "text" >Saab</ div > |
19 |
< div class = "description" >Description about Saab</ div > |
22 |
< input class = "value" value = "text1" type = "hidden" > |
23 |
< div class = "-clear-both" ></ div > |
28 |
< img class = "image" src = "Mercedes.jpg" > |
31 |
< div class = "text" >Mercedes</ div > |
32 |
< div class = "description" >Description about Mercedes</ div > |
34 |
< input class = "value" value = "text2" type = "hidden" > |
35 |
< div class = "-clear-both" ></ div > |
4. Default configuration options to customize the drop down list.
01 |
$( "#mySelect" ).gorillaDropdown({ |
02 |
arrowColor : "#808080" , |
03 |
arrowDown : "▼" , |
06 |
backgroundColor : "#ffffff" , |
07 |
borderColor : "#c0c0c0" , |
09 |
descriptionFontColor : "#000000" , |
10 |
descriptionFontFamily : "Verdana" , |
11 |
descriptionFontSize : "12px" , |
12 |
descriptionFontStyle : "normal" , |
13 |
descriptionFontVariant : "small-caps" , |
14 |
descriptionFontWeight : "normal" , |
15 |
displayArrow : "inline" , |
16 |
dropdownHeight : "auto" , |
17 |
hoverColor : "#f0f8ff" , |
18 |
imageLocation : "left" , |
19 |
onSelect : function () {}, |
21 |
placeholder : "Select" , |
22 |
placeholderFontColor : "#808080" , |
23 |
placeholderFontFamily : "Verdana" , |
24 |
placeholderFontSize : "14px" , |
25 |
placeholderFontStyle : "italic" , |
26 |
placeholderFontVariant : "normal" , |
27 |
placeholderFontWeight : "bold" , |
29 |
textFontColor : "#000000" , |
30 |
textFontFamily : "Verdana" , |
31 |
textFontSize  
source : jqueryscript.net
|