Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltip or comment for select options

Im using bootstrap select for my dropdowns. Im interested is it possible to add a comment or a tooltip for each option that would pop up immediatly when i hover my mouse over it? Each comment is about 20-30 words long so it dosent fit well into the list.

At the moment i just have the select element:

<select class="selectpicker" multiple="">
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</select>
$('select').selectpicker();

http://jsfiddle.net/mfrup5bL/136/

like image 766
user1985273 Avatar asked Oct 19 '17 05:10

user1985273


People also ask

What is tooltip used for?

Definition: A tooltip is a brief, informative message that appears when a user interacts with an element in a graphical user interface (GUI). Tooltips are usually initiated in one of two ways: through a mouse-hover gesture or through a keyboard-hover gesture.

Can tooltips be clickable?

As we mentioned in the preamble, tooltips are completely "mute" to any interactions as to not steal hover events from elements underneath them. Even placing interactive elements, such as links, into content of tooltip will not work.

What is tooltip give an example?

A tooltip is a small section of text that is designed to explain how one particular element of your product works. It normally appears when a user hovers over the element in question, or a little “i” icon that's next to the element.

What is a hover tooltip?

A tooltip, also known as screentips or hover help, is an overlay or callout that appears in certain parts of the user workflow on a digital product, containing helpful hints about less intuitive features.


1 Answers

Take a look at this, it works well with bootstrap select. The bootstrap select is an unordered list of your select options.

$(".selectpicker").selectpicker()
var title = [];
$('#mySelect option').each(function(){
    title.push($(this).attr('title'));
});

$("ul.selectpicker li").each(function(i){
  $(this).attr('title',title[i]).tooltip({container:"#tooltipBox"});
})
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
    <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.5/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.min.js"></script>
    		<div class="col-sm-6" style="margin-top:10px;">
    				<select class="selectpicker form-control" id="mySelect" multiple>
    					<option title="Option 1">option one</option>
    					<option title="Option 2">option two</option>
    					<option  title="Option 3">Option three</option>
    					<option title="Option 4">Option four</option>
    					</select>
              <p id="tooltipBox" class="col-sm-6" style="z-index:9999;"></p>
    				</div>
like image 187
Abk Avatar answered Oct 05 '22 16:10

Abk