Home > Web Front-end > JS Tutorial > jQuery flat style drop-down box beautification plug-in FancySelect usage guide_jquery

jQuery flat style drop-down box beautification plug-in FancySelect usage guide_jquery

WBOY
Release: 2016-05-16 16:14:34
Original
1330 people have browsed it

FancySelect is a small and practical jQuery drop-down box beautification plug-in. This drop-down box beautification plug-in adopts a flat design style and is one of the first choice drop-down box beautification plug-ins for developers who pursue fashion.

How to use

HTML structure

FancySelect is very simple to use and can be used in conjunction with jQuery or Zepto. Place some element. You can use this method to specify different styles of select drop-down boxes.

Copy code The code is as follows:


JAVASCRIPT

Copy code The code is as follows:

$('.basic').fancySelect();

Update options

If the options of your drop-down box are modified after the plugin is initialized, you can tell the plugin to update the options list by triggering the update.fs method on the drop-down box.

Copy code The code is as follows:

var mySelect = $('.my-select');
mySelect.fancySelect();
mySelect.append('');
mySelect.trigger('update.fs');

Enable/disable drop-down box

The FancySelect drop-down box plug-in will automatically set the drop-down box to the disabled state after initialization. If you need to reset the state of the drop-down boxes, you can use the enable.fs or disable.fs methods on the select element to modify them.

Copy code The code is as follows:


var mySelect = $('.my-select');
mySelect.fancySelect(); // currently disabled because of html property
// later…
mySelect.trigger('enable.fs'); // now enabled
// even later…
mySelect.trigger('disable.fs'); // now disabled again

If you need to create some personalized effects, you can use the triggerTemplate and triggerTemplate methods, which both return an HTML string through the option option:

Copy code The code is as follows:


$('.bulbs').fancySelect({
optionTemplate: function(optionEl) {
          return optionEl.text() '
'; } })

You can listen to the change.fs event when the
   
   

var mySelect = $('.my-select');
mySelect.fancySelect().on('change.fs', function() {
    $(this).trigger('change.$');
}); // trigger the DOM's change event when changing FancySelect

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template