


jQuery uses the Selectator plug-in to implement a multi-select drop-down list filter box (with source code download)_jquery
Selectator is a jQuery drop-down list box plug-in that implements multi-selection and search filtering functions. It supports searching and can directly affect the original select box, which is used as a data container. Through this drop-down list box plug-in, you can group multiple options, set the icons of the options, search and filter the options, and perform multi-select selections.
Effect display Source code download
How to use
To use this drop-down category box plug-in, you need to introduce the fm.selectator.jquery.css, jQuery and fm.selectator.jquery.js files into the page.
<link rel="stylesheet" href="fm.selectator.jquery.css"/> <script src="jquery-1.11.0.min.js"></script> <script src="fm.selectator.jquery.js"></script>
HTML structure
The HTML structure of a drop-down list with icon level and grouping options is as follows:
<label for="select"> Multi select with custom content: </label> <select id="select" name="select" multiple> <optgroup label="Group one" class="group_one"> <option value="1" class="option_one" data-subtitle="Et" data-left="<img src='images/ingi.png'>" data-right="1">One</option> <option value="2" class="option_two" data-subtitle="To" data-left="<img src='images/runa.png'>" data-right="2">Two</option> </optgroup> <optgroup label="Group two" class="group_two"> <option value="3" class="option_three" data-subtitle="Tre" data-left="<img src='images/jogvan.png'>" data-right="3">Three</option> <option value="4" class="option_four" selected data-left="<img src='images/noimage.png'>" data-right="4">Four</option> <option value="5" class="option_five" selected data-left="<img src='images/noimage.png'>" data-right="5">Five</option> <option value="6" class="option_six">Six</option> </optgroup> <optgroup label="Group three" class="group_three"> <option value="7" class="option_seven">Seven</option> </optgroup> <option value="8" class="option_eight" data-subtitle="Otte">Eight</option> <option value="9" class="option_nine">Nine</option> <option value="10" class="option_ten" selected>Ten</option> <option value="11" class="option_eleven" selected>Eleven</option> <option value="12" class="option_twelve">Twelve</option> <option value="13" class="option_thirteen">Thirteen</option> <option value="14" class="option_fourteen">Fourteen</option> </select> <input value="activate selectator" id="activate_selectator4" type="button">
Initialize plugin
After the page DOM element is loaded, the drop-down list plug-in can be initialized through the selector() method.
$('#selectBox').selectator();
You can also initialize it directly using tags:
<select multiple class="selectator" data-selectator-keep-open="true">
Configuration parameters
$('#selectBox').selectator({ prefix: 'selectator_', // CSS class prefix height: 'auto', // auto or element useDimmer: false, // dims the screen when option list is visible u**arch: true, // if false, the search boxes are removed and // `showAllOptionsOnFocus` is forced to true keepOpen: false, // if true, then the dropdown will not close when // selecting options, but stay open until losing focus showAllOptionsOnFocus: false, // shows all options if input box is empty selectFirstOptionOnSearch: true, // selects the topmost option on every search searchCallback: function(value){}, // Callback function when enter is pressed and // no option is active in multi select box labels: { search: 'Search...' // Placeholder text in search box in single select box } });
Other available attribute tags
You can extend the display information of the drop-down list by using the data-left, data-right and data-subtitle tags. They can be styled via CSS, with the prefixes prefix_title, prefix_left, prefix_right and prefix_subtitle. The data is all pure HTML code, so you can use image code as well.
<select id="selectBox"> <!-- Normal option tag --> <option value="1">This is the title</option> <!-- Extended option tag --> <option value="2" data-left="This is the left section" data-right="This is the right section" data-subtitle="This is the section under the title">This is the title</option> </select>
will appear as a structure similar to the following:
CSS Class
class | Description |
prefix_element | This is a new drop-down list box. It comes with the same extra classes: single and multiple , which are used to set whether it is single selection or multiple selection.Also options-visible and options-hidden Used to set whether the option is visible |
prefix_chosen_items | Container for selected options |
prefix_chosen_item | Container for the currently selected option |
prefix_chosen_item_title | The title of the currently selected option |
prefix_chosen_item_left | The content to the left of the currently selected option |
prefix_chosen_item_right | The content to the right of the currently selected option |
prefix_chosen_item_subtitle | The subtitle of the currently selected option |
prefix_chosen_item_remove | Remove button for the currently selected option |
prefix_input | This is the input box for the selector. This is used together with options-visible or options-hidden to show and style it differently if it is a multiple selection box or a single selection box. |
prefix_textlength | Used to calculate the size of the input in the multiple selection box |
prefix_options | Option list container |
prefix_group_header | Group title |
prefix_group | Group container |
prefix_option | Result options.It uses class active to indicate the currently activated option |
prefix_option_title | Title of result option |
prefix_option_left | Content to the left of the results options |
prefix_option_right | The content on the right side of the result options |
prefix_option_subtitle | Subtitle to the right of the results options |
prefix_dimmer | dimmer |
Method
方法 | 描述 |
refresh | 该方法用于刷新插件 |
destroy | 该方法用于销毁插件 |
The github address of jquery.selectator-custom drop-down list plug-in is:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

Explore the implementation of panel drag and drop adjustment function similar to VSCode in the front-end. In front-end development, how to implement VSCode similar to VSCode...
