如何将图像图标添加到引导程序选择选项

dsd*_*dsd 7 options css3

只是想知道是否可以将图标/图像添加到Bootstrap选择选项.
我已经通过在HERE中为选项添加背景图像来尝试此操作

<select class="span2">
            <option>1</option>
            <option style="background-image:url(slider-dot.png);">2</option>
            <option>3</option>
</select>
Run Code Online (Sandbox Code Playgroud)

但它不起作用!如果可能的话,能告诉我吗?谢谢

Jua*_*lla 13

据我所知,您无法使用内置的引导程序设置向选项元素添加图标.但是,有一个为bootstrap构建的插件用于执行此功能,还添加了其他自定义选项来引导选择组件.它被称为bootstrap-select.

用于此插件的图标直接从bootstrap提供的Glyphicons加载.

编辑:请参阅jsFiddle的链接示例:http://jsfiddle.net/YW8MV/5/

相关的JavaScript是这样的:

$('.selectpicker').selectpicker({
    style: 'btn-primary',
    showIcon: true,
    title: 'select test'
});
Run Code Online (Sandbox Code Playgroud)