1

I have a selectpicker with many languages i.e. <li> tags under <ul> tag as below given image.

Drop Down List (selectpicker)

It can be seen that the + Add Language li of selectpicker is disabled. It is happening because in actual html's <select>'s option is disabled as following image

HTML view

Now the concern is: selectpicker picks the select option and apply all the properties but did not carry the title (it can bee seen on <select>'s <option> value; title="My Title") while hover over the disabled <li> tag. In my opinion it is happening because disabled class on this <li> tag is overriding the title behavior by adding that ban icon.

Please let me know how can I enable this behavior while using select picker. I want title to be displayed while hovering over the disabled option.

Edit: Kindly refer to the code snippet for better understanding.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet"/>
Language:
<select class="selectpicker">  
    <option>English</option>
    <option disabled title="My Title">+ Add Language</option>    
</select>

4

2 回答 2

1

你可以使用属性data-content

从文档:

<select class="selectpicker">
  <option data-content="<span class='label label-success'>Relish</span>">Relish</option>
</select>

使用此属性,您可以将输出“模板”传递给您可以设置title属性。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css" rel="stylesheet"/>

Language:
<select class="selectpicker">  
    <option data-content="<span title='English'>English</span>">English</option>
    <option disabled title="My Title" data-content="<span title='+ Add Language'>+ Add Language</span>">+ Add Language</option>    
</select>

于 2016-07-27T10:27:04.230 回答
0

根据顶部,这是我的代码:

<select class="selectpicker"> 
    <option value="add" data-content='<span data-toggle="tooltip" data-placement="bottom" title="My Tooltip Title">+ Add Language</span>'>+ Add Language</option>
</select>
于 2018-05-08T07:20:53.063 回答