2013-08-21 31 views
0

我想在該羣組中添加羣組標籤,我如何實現這一目標?淘汰賽js dropdownlist羣組圖片

例如該圖像 enter image description here

在這裏,我想在歐洲,NorthAmercia,南美洲組

代碼是在這裏設置的圖像,

<select data-bind="foreach: groups, value: selectedOption"> 
    <optgroup data-bind="attr: {label: label}, foreach: children"> 
     <option data-bind="text: label, option: $data"></option> 
    </optgroup> 
</select> 


<hr /> 

更多的代碼是在這裏:http://jsfiddle.net/rniemeyer/aCS7D/

回答

1

如果您想在選項中使用圖片等內容,您可能需要查看使用像select2這樣的插件。查看該文檔頁面上的「模板」示例,其中包含圖像示例。

+0

但我需要圖像在groupnames,我無法找到那裏的例子,我真的不喜歡使用插件:),我們不能把圖像和標籤放在optgroup? – patel

+0

不,您不能將圖像放置在optgroup或選項元素 –

+2

這裏是一個格式化optgroup的快速示例:http://jsfiddle.net/rniemeyer/ws4Mq/ –