skip to Main Content

I’ve a country list with selectize. But I want to also include the flag of each country before the name of the country.

I haven’t found any info about this yet. I was wondering if this is possible and how to achieve.

I’m using just html css and js with jquery.

2

Answers


  1. Well, if you follow standars for country code, you can use an API, lik this one:

    enter link description here

    Login or Signup to reply.
  2. Yep, it’s possible to render custom children in selectize according to this example.

    Check out the render key, you should be able to add an <img> tag in there. I made a little example of what I think you’re asking for:

    html

    <div class="selectItem">
      <span class="flag">πŸ‡ΊπŸ‡Έ</span>
      <span class="text">Some text</span>
    </div>
    

    css

    .selectItem {
      width: 200px;
      border: 1px solid black;
    }
    
    .flag {
      border-right: 1px solid black;
      padding: 2px;
    }
    

    Simply place the markup in place of the value in the example and that should give you something like what you’re looking for I think

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search