首先学习这个东西呢,还是看官网比较全面
select2官网例子
要select2中文显示:必须要引入中文包,且一定要放在select2.js之后
<link type="text/css" href="http://blog.csdn.net/css/select2.css"> <script type="text/javascript" src="http://blog.csdn.net/js/select2.full.min.js"></script> <script type="text/javascript" src="http://blog.csdn.net/js/i18n/zh-CN.js"></script></span> $(".selectProduct").select2({ ajax: { url: "getProducts", dataType: 'json', type: 'POST', delay: 250, data: function (params) { var param = new Object(); param.name = params.term; return param; }, processResults: function (resp, page) { var array = new Array(); if (resp.products) { for (var i = 0; i < resp.products.length; i++) { var product = resp.products[i]; array.push({id:product.productId, text: product.productName}); } } var ret = new Object(); ret.results = array; return ret; }, cache: true }, minimumInputLength: 2, language: "zh-CN", }); </span>Tags:jquery select2 jquery插件