HTML Select Object Extension with Framework | jQuery treeSelection

Tree selection is tree browsing like the jQuery multi-select plugin that allows the user to select single or multiple options using radio buttons or checkboxes.

Expand the functionality of the existing HTML selection control, increase the tree list mode, and the upper limit on the number of multiple selections.

Must Read: Hierarchical Tree With Radio Buttons Using Vanilla JS and Bootstrap | ninotree

How to make use of it:

1. Import the jQuery treeSelection plugin stylesheet and javascript.

<link href="/path/to/jquery.treeSelection.css" rel="stylesheet" />
<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/jquery.treeSelection.js"></script>

2. Convert a normal select box into a multi-select component using radio buttons.

<select name="mySelect" class="custom-select" multiple>
  <optgroup label="Alaskan/Hawaiian Time Zone">
    <option value="AK">Alaska</option>
    <option value="HI">Hawaii</option>
  </optgroup>
  <optgroup label="Pacific Time Zone">
    <option value="CA">California</option>
    <option value="NV">Nevada</option>
    <option value="OR">Oregon</option>
    <option value="WA">Washington</option>
  </optgroup>
  <optgroup label="Mountain Time Zone">
    <option value="AZ">Arizona</option>
    <option value="CO">Colorado</option>
    <option value="ID">Idaho</option>
    <option value="MT">Montana</option><option value="NE">Nebraska</option>
    <option value="NM">New Mexico</option>
    <option value="ND">North Dakota</option>
    <option value="UT">Utah</option>
    <option value="WY">Wyoming</option>
  </optgroup>
</select>

3. Import jQuery tree selection plugin stylesheet and javascript.

$(function(){
  $('select[name=mySelect]').treeSelection();
});

4. You are also allowed to define options in a JS array as follows:

<select name="mySelect" class="custom-select">
  
</select>
$('select[name=mySelect]').treeSelection({
  data: [{
    name: 'Google',
    items: [{
      name: 'Search Tools',
      items: ['Google Search', 'Google Alerts', 'Google Scholar']
    },{
      name: 'Advertising Services',
      items: ['Google Ads','AdMob','Google AdSense']
    }]
  }, {
    name: 'Apple',
    items: [{
      name: 'iPhone',
      items: ['iPhone 13','iPhone 12','iPhone SE']
    },{
      name: 'Apple Watch',
      items: ['Watch 7','Watch SE']
    }]
  }, {
    name: 'Amazon',
    items: ['Amazon Prime','Amazon Web Services','Consumer Electronics']
  }]
});

5. Add additional CSS styles and/or classes to the multi-select dropdown.

$('select[name=mySelect]').treeSelection({
  style: '',
  class: '',
});

See Demo And Download

Official Website(windy2006): Click Here

This superior jQuery/javascript plugin is developed by windy2006. For extra Advanced Usage, please go to the official website.

Related Posts

Cookie-Consent-Using-Bootstrap

How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…

Create-HTML-Terminals

Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…

Bootstrap-Alert-Bootbox

Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…

Slider-fg-carousel

An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….

Tags-Input-Component

A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…

copy-to-clipboard-javascript

A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…