Giter Site home page Giter Site logo

merh-select's Introduction

merh-select

Merh-Select – no fuzz Vanilla JS dropdown select

Features:

  • Fully Customizable
  • Zero Dependencies, built with Vanilla Javascript
  • Accept images or icon
  • Multiple or Single select

Installation:

  1. Include Javascript
<script src="path/to/merhselect.js">
  1. Include CSS
<link rel="stylesheet" href="path/to/merhselect.css">
  1. HTML
<select id="merh-select"></select>
  1. Initialize
const filter = new merhSelect({
  selectorID: 'merh-select',
  options: [
    ['visible value 1', 'data-value 1', 'path/to/image'],
    ['visible value 2', 'data-value 2', 'path/to/image'],
    ['visible value 3', 'data-value 3', 'path/to/image'],
  ],
});
  
const dropdown = document.getElementById(filter.selectorID)
dropdown.addEventListener('updated', () => {
    console.log(filter.selected())
});

Visible value, are values that are seen from client point of view. Data value, are values that will be referenced.
Example: your if option value is 'youtube-video', you can set the visible value to 'yt-video' instead.

Path to image is optional, if omitted there will be no icon/image beside value

Options:

Name Data-Type Description
placeholder string placeholder string or first option value
multiple boolean multiple select or single select
autoClose boolean Only applicable to multi-select, close dropdown box whenever a option is selected
firstOptionReset boolean Only applicable to multi-select, de-select all option when first option is selected

Methods:

  1. Get Selected Values: return data-value of selected option(s)
const selected = filter.selected()
  1. Set current dropdown value: select change dropdown value to selected option
filter.set('data-value 3')

merh-select's People

Contributors

merhmerh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.