Search code examples
jqueryhtmlcssjquery-select2font-awesome

How to insert FontAwesome inside Select2


I have no idea how to insert fontawesome inside Select2. What should I add the CSS or JS in it? I have a view like below.

click : http://s10.postimg.org/675fig9vd/Capture121212121.png

Can anyone help me?


Solution

  • Based on my plugin WP Mobile Splash Page Editor, I made a quick fiddle: http://jsfiddle.net/SiamKreative/qCn6p/

    function format(icon) {
        var originalOption = icon.element;
        return '<i class="fa ' + $(originalOption).data('icon') + '"></i> ' + icon.text;
    }
    $('.wpmse_select2').select2({
        width: "100%",
        formatResult: format
    });