JQuery flattened style drop-down box beautification plug-in FancySelect User Guide _ jquery

Source: Internet
Author: User
This article mainly introduces the FancySelect use guide for jQuery's flat style drop-down box beautification plug-in. For more information, see FancySelect, a small and practical jQuery drop-down box beautification plug-in. The drop-down box beautification plug-in adopts a flat design style and is one of the preferred drop-down box beautification plug-ins for fashion developers.

Usage

HTML Structure

FancySelect is very simple to use. It can be used with jQuery or Zepto. Place someDrop-down box components, and then you can use the. fancySelect () method to call the drop-down box plug-in. If there is no value for an option in the drop-down box, the plug-in will replace it with some placeholder text.By default, FancySelect only uses native drop-down boxes and styles on iOS devices. If you want to overwrite it, set forceiOS to true during plug-in Initialization in the drop-down box.FancySelect can also passThe data-class attribute of the element to specify the style. You can use this method to specify the select drop-down box for different styles.

The Code is as follows:


Select something... Lorem Ipsum Dolor Sit Amet

JAVASCRIPT

The Code is as follows:


$ ('. Basic'). fancySelect ();

Update options

If the options in the drop-down box is modified after the plug-in is initialized, You can trigger the update. fs method in the drop-down box to notify the plug-in to update the options list.

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 automatically sets the drop-down box to disabled after initialization. If you need to reset the status of the drop-down box, you can use the enable. fs or disable. fs method on the select element to modify them.

The Code is as follows:


First Option Second Option
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 make some personalized effects, you can use the triggerTemplate and triggerTemplate methods. They all return an HTML string through the option:

The Code is as follows:


Incandescent CFL Halogen
$ ('. Bulbs'). fancySelect ({
OptionTemplate: function (optionEl ){
Return optionEl. text () +'
';}})

You canListen to the change. fs event when the drop-down box option is changed: The Code is as follows:
First Option
Second Option

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.