2017-02-24 56 views
0

https://jsfiddle.net/hodtfkys/3/中,我怎樣才能讓它始終顯示圖像,如http://jsfiddle.net/t9vfxo5t/所示,而不僅僅是當用戶放下列表時?語義UI下拉 - 將圖像顯示爲圖標?

圖片只有當下拉點擊:

<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> 

圖標總是顯示:

<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> 

回答

5

嗨它好像你正在使用data-text='Male'data-text='Female'即創建issue.Removing將解決問題,更新後的代碼如下。

<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>