Semantic UI dropdown - display image as icon?

In https://jsfiddle.net/hodtfkys/3/ , how can I get it to always display the image as shown in http://jsfiddle.net/t9vfxo5t/ , not just when the user drops down the list?

Image only when dropdown clicked:

<div class='ui icon selection dropdown'>
  <input name='DropDownListCategoryClone' type='hidden'> <i class='dropdown icon'></i>
  <div class='default text'>
    Male
  </div>
  <div class='menu'>
    <div class='item' data-text='Male' data-value='male'>
      <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Male-icon.png' style='width:20px;'> Male
    </div>
    <div class='item' data-text='Female' data-value='female'>
      <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Female-icon.png' style='width:20px;'> Female
    </div>
  </div>
</div>

Icon always displaying:

<div class="ui selection dropdown">
    <input type="hidden" name="language">
    <i class="dropdown icon"></i>
    <div class="default text">Select language</div>
    <div class="menu">
        <div class="item" data-value="gb"><i class="gb flag"></i>English</div>
        <div class="item" data-value="es"><i class="es flag"></i>Spanish</div>
    </div>
</div>

Answers 1

  • Hi its seems like you are using the data-text='Male' and data-text='Female' which is creating the issue.Removing it will solve the issue, updated code given below.

        <div class='ui icon selection dropdown'>
      <input name='DropDownListCategoryClone' type='hidden'>
      <i class='dropdown icon'></i>
      <div class='default text'> Select Gender</div>
      <div class='menu'>
        <div class='item' data-value='male'>
          <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Male-icon.png' style='width:20px;'> Male
        </div>
        <div class='item' data-value='female'>
          <img class='ui image' src='http://icons.iconarchive.com/icons/icons8/ios7/512/Users-User-Female-icon.png' style='width:20px;'> Female
        </div>
      </div>
    </div>
    

Related Articles