2015-09-04 81 views

回答

2

使用Selecize API,你可以用這個方法選擇:

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

然後遍歷對象指望他們:

var cnt = 0; 
for(k in options){ 
    cnt++; 
} 
console.log(cnt); 
+0

謝謝ahmed。它解決了我的問題:D –

2

獲取selectize的所有選項

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

獲取對象的所有密鑰

let count = Object.keys(options); 
console.log(count.length);