BVSelect - VanillaJS Fully Customizable SelectBoxes

栏目: IT技术 · 发布时间: 5年前

内容简介:Replaces native select elements with fully customizable dropdowns.Even though this replaces native select options, you can still use

BVSelect - Vanilla JS

BVSelect - VanillaJS Fully Customizable SelectBoxes

Replaces native select elements with fully customizable dropdowns.

Even though this replaces native select options, you can still use Form Submit , Onchange Events and Attributes as you would with normal usage.

Demo:

https://bmsvieira.github.io/BVSelect-VanillaJS/

JQuery Version:

https://github.com/BMSVieira/BVSelect

Features:

  • :wrench: Fully Customizable
  • :muscle: No Dependencies, built with VanillaJS
  • :earth_americas: Tested in All Modern Browsers (IE11 not Included)
  • :sunglasses: Images & FontIcons
  • ⌨️ Normal Usage (Multiple Selection included)
  • :mag_right: Built-in Searchbox
  • Prevented Viewport Overflow

Installation:

1 - Include JavaScript Source.

<script src="path/to/bvselect.js"></script>

2 - Include Styles.

<link rel="stylesheet" href="path/to/bvselect.css">

4 - Set HTML.

<select id="selectbox">
  <option data-separator="true"> Select Option </option>
  <option value="1"> Option 1 </option>
  <option value="2"> Option 2 </option>
  <option value="3" disabled> Option 3 </option>
  <option value="4"> Option 4 </option>
</select>

3 - Initilize.

document.addEventListener("DOMContentLoaded", function() {
        var demo1 = new BVSelect({
          selector: "#selectbox",
          searchbox: true,
          offset: true
        });
  });

Methods:

Destroy:

demo1.Destroy();

Removes dropdown, unbinds all its events and brings back the original Select

Update:

demo1.Update();

Updates current dropdown based on changes to the original selectbox.

Get ID:

demo1.GetID();

Returns the ID that was generated to build dropdown, so you can add custom classes.

Settings:

Name Value Default Description
width px or % 100% Specify the width of the main element
searchbox true or false false Add a search box to the list
offset true or false true Fixes Viewport Offset

Example:

document.addEventListener("DOMContentLoaded", function() {
        var demo1 = new BVSelect({
          selector: "#selectbox",
          searchbox: true,
          offset: true
        });
  });

Attributes:

Name Value Description
data-separator true or false Highlights an option
data-img Image Source Adds an Image to option
data-icon fa fa-hashtag Adds an FontIcon to option, can be used any provider as long it is identical. Images will be prioritized over icons.
disabled (native) disabled Disables an option

To add FontIcons, you must include it's own sources

Example:

<select id="selectbox">
    <option value="##" data-separator="true" selected>Select Option</option>
    <option data-img="path/to/img.png" value="--">Cristiano Ronaldo</option>
    <option data-icon="fa fa-hashtag" value="--" >Lionel Messi </option>
    <option data-img="path/to/img.png" value="--" disabled>Neymar Jr. (Disabled)</option>
    <option data-img="path/to/img.png" value="--">Ronaldinho</option>
    <option data-img="path/to/img.png" value="--">Luis Figo</option>
</select>

All CSS styles are fully customizable in order to match your style

Frequently Asked Questions

Is there any themes?

It doesn't need themes since the CSS is fully customizable, you are able to change everything to match your style.

In addition to design, what changes?

Replaces the original SelectBox but you can use it as you would with a native one, OnChange Events, Attributes, Form Submit, Append/Remove Options, everything.

What about Browser Compatibility?

It was tested successfully in every modern browser (IE11 not Included)


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

数据结构

数据结构

霍罗威茨 / 机械工业出版社 / 2006-7-1 / 48.00元

《数据结构》(C语言版)针对采用ANSI C实现数据结构进行了全面的描述和深入的讨论。书中详细讨论了栈、队列、链表以及查找结构、高级树结构等功能,对裴波那契堆、伸展树、红黑树、2-3树、2-3-4树、二项堆、最小-最大堆、双端堆等新的数据结构进行了有效分析。《数据结构》(C语言版)对一些特殊形式的堆结构,诸如应用在双端优先队列中的最小-最大堆和双端堆的数据结构以及左高树、裴波那契堆、二项堆等数据结......一起来看看 《数据结构》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具