How to add html placeholder to select2?

后端 未结 4 1676
南旧
南旧 2021-01-18 06:39

I want to add one icon to placeholder like this

$(\"#tag_list\").select2({
    allowClear: true,
    placeholder: \"         


        
4条回答
  •  执念已碎
    2021-01-18 07:02

    function format(state){
    
    if (!state.id) {
    
    return state.text; // optgroup
    
    } else {
    
    return "" + state.text;
    
    }
    
    }
    
    $("#tag_list").select2({
    
        formatResult: format,
    
        formatSelection: format,
    
        escapeMarkup: function(m) { return m; }
    
    
    });
    

    http://ivaynberg.github.io/select2/

提交回复
热议问题