0
我創建了select2下拉菜單。現在,我想在此下拉菜單中按國名添加說明,城市,商店等。 如何添加國家城市名稱,地區,商店等?Select2顯示更多值
(function($) {
$(function() {
var isoCountries = [
{ id: 'QA', text: 'Qatar',},
{ id: 'CA', text: 'Canada'},
{ id: 'CN', text: 'China'},
{ id: 'DE', text: 'Germany'},
{ id: 'RU', text: 'Russia'},
{ id: 'IT', text: 'Italy'}
];
$("[name='market']").select2({
placeholder: "Select a country",
data: isoCountries
});
});
})(jQuery);
https://select2.github.io/examples.html#data-ajax 使用此選項,編輯選擇2的查看HTML: 'formatSelection:功能(項目){ 回報item.text +' '+ item.xxx; //一些其他屬性 }' – lakshay
請參閱示例頁面源代碼(Ctrl + U)以查看額外數據顯示在html中的select2 – lakshay