多選标簽: | 卡卡西 鳴人 佐助 小櫻 波風水門 大蛇丸 綱手 自來也 |
單選标簽: | 請選擇... 卡卡西 鳴人 佐助 小櫻 波風水門 大蛇丸 綱手 自來也 |
$(function(){
$('#sel_productTag').select2({
placeholder: "請至少選擇一個人名",
tags:true,
createTag:function (decorated, params) {
return null;
},
width:'256px'
});
function formatState (state) {
if (!state.id) { return state.text; }
var $state = $(
'' + state.text + ''
);
return $state;
};
$('#sel_recommender').select2({
placeholder: "請選擇一個人名",
templateResult: formatState,
width:'256px'
});
});
ps:清空可用$("#sel_productTag").select2("val", ""); 方法,可參考http://download.csdn.net/detail/liu765023051/8827491
本文來源于網絡:檢視 >https://blog.csdn.net/Nightliar/article/details/70230847