}functiongetvalue(){varinfo = $(".test").select2('data');alert('数据类型:'+typeofinfo);alert("数据值:"+JSON.stringify(info)); }functiongetvalue_(){varinfo = $('.test').find(':selected').data('own');//调用自定义 'own' 属性alert(JSON.stringify(info)); }functionjud_init(){i...
{id: 1, text:'OPS-COFFEE-1'}, {id: 2, text:'OPS-COFFEE-2'}, {id: 3, text:'OPS-COFFEE-3'} ] $('#id_select2_demo2').select2({ data: sdata }); select2能够加载的数据格式如上,需要两个数据属性id和text,当然你也可以加载其他的额外属性以在需要时获取 加载远程数据 除了加载本地...
text: 'task'}] }); // 加载数组 支持多选 $("#e11_2").select2({ createSea...
text(); }); // doing a diff of old_values gives the new values selected var last = $(values).not(old_values).get(); // update old_values for future use old_values = values; // output values (all current values selected) console.log("selected values: ", values); // output las...
<selectid="sel_menu3"class="js-data-example-ajax form-control"><optionvalue="3620194"selected="selected">请选择</option></select> $(function(){//远程筛选$("#sel_menu3").select2({ajax:{url:"/Home/GetProvinces",dataType:'json',delay:250,data:function(params){return{q:params.term,/...
text: 'test'};var newOption = new Option(data.text,data.id,false,false); $('#testselect').append(newOption).trigger('change'); 如果是选取若干个可以传递一个数组给val方法。如果需要对待加入项是否已经存在做出判断的话可以这么做: if ($('#testselect').find('option[value='+data.id+']')...
var loadingMore = this.options.get('translations').get('searching'); var loading = { disabled: true, loading: true, text: loadingMore(params) }; var $loading = this.option(loading); $loading.className += ' loading-results'; ...
original = stripDiacritics(data.text).toUpperCase().indexOf(term); } } 1 2 3 4 5 6 7 8 9 10 11 12 三、常用功能说明 1.常用参数设置含义 tags: true, // 根据搜索框创建option,默认false maximumSelectionLength: 6, // 最多能够选择的个数 multiple: true, // 多选,默认false data: initdata...
<selectid="sel_menu3"class="js-data-example-ajax form-control"><optionvalue="3620194"selected="selected">请选择</option></select> $(function() {//远程筛选$("#sel_menu3").select2({ ajax: { url:"/Home/GetProvinces", dataType:'json', ...
The following options are important: multiple: boolean whether multiple or single item should be selected. placeholder or prompt: string placeholder text for the select item. To set a placeholder, you must set one of placeholder or prompt....