Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count number of options in selectize.js

how to count number of options in dropdown using selectize.js?

$('#MyDrop option').length;

$('#MyDrop option').size();

Above ones are not working with selectize !

like image 993
Muhmmad Abubakar Ikram Avatar asked Dec 24 '22 14:12

Muhmmad Abubakar Ikram


1 Answers

Get all options of selectize

let options = $('#selectElem')[0].selectize.options;

Get all keys of object

let count = Object.keys(options);
console.log(count.length);
like image 155
ravins Avatar answered Dec 27 '22 05:12

ravins