Sofyan Setiawan Sofyan Setiawan - 1 year ago 122
jQuery Question

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 :

Can anyone help me?

Answer Source

Based on my plugin WP Mobile Splash Page Editor, I made a quick fiddle:

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

Hope that helps ;)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download