将有选项在bootstrap multiselect中显示图像而不是选定的文本

时间:2015-06-03 08:11:15

标签: javascript jquery css html5 twitter-bootstrap

我们是否有任何选项可以将图像显示为默认值。

代码:

 <select id="example-post" style="width:120px;!important;" class="footerSelect" name="multiselect[]" multiple="multiple">
                                            <option value="1">test</option>
                                            <option value="2">test1</option>
                                            <option value="3">test2 </option>             

 $('.multiselect-selected-text').text('Options');

enter image description here

此处我想要将图像显示为默认值而不是选项。

1 个答案:

答案 0 :(得分:1)

试试这个......

<div class="pull-left">
    <div class="pull-right">
        <div class="btn-group">                 
                <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
                    <span>Actions</span>
                    <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                    <li class="ok"><a href="#">Item 1</a></li>
                    <li><a href="#">Item 2</a></li>
                    <li class="ok"><a href="#">Item 3</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Item 4</a></li>
                    <li><a href="#">Item 5</a></li>

                </ul>
            </div>
    </div>
</div>

@import url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');

.container {
    margin-top: 10px;
}

.dropdown-menu li:nth-of-type(1) { 
    background-image: url("http://files.softicons.com/download/application-icons/32x32-free-design-icons-by-aha-soft/png/32/Color%20test.png") !important; 
    background-repeat: no-repeat;
    background-size: 16px 16px;
    background-position: 3px 5px;
    padding-left: 5px;
}

.dropdown-menu li:nth-of-type(2) { 
    background-image: url("http://files.softicons.com/download/application-icons/32x32-free-design-icons-by-aha-soft/png/32/Color%20test.png") !important; 
    background-repeat: no-repeat;
    background-size: 16px 16px;
    background-position: 3px 5px;
    padding-left: 5px;
}