问题
Hi iam working on chosen jquery plugin and i need to add tooltip to all the elements in chosen plugin. I tried tweaking around in chosen but didn't get any positive result. Does anyone have any idea?
Code:
<div id="synonyms_div" style="height:auto;width:170px;">
<select id="tagger-tags" class="tagger-tags" multiple style="width:150px; font:7px;" tabindex="4">
@foreach(var tag in ViewBag.tags)
{
<option id="sel-tags" value="@tag.ID" parent="@tag.PARENT_ID" style="font:6px;">
@tag.NAME [@tag.EL_COUNT]
</option>
}
</select>
</div>
<script>
$(document).ready(function () {
jQuery(".tagger-tags").chosen({ search_contains: true });
});
</script>
回答1:
Here's a possible solution without having to use any other libraries, or anything else... This can be accomplished with a bit of CSS.
HTML:
<!--// we have to wrap the select in a span to use :after with it //-->
<span class="tooltip" title="some title for your tooltip">
<select>
<option>Something</option>
<option>Something Else</option>
</select>
</span>
CSS:
.tooltip:hover:after {
position: relative;
/* we can get the title attribute from the relevant item */
content: "" attr(title) "";
/* style however you want */
border: 1px dashed black;
top: -1.5em;
left: 12em;
padding: 0.5em;
}
Will give you something like:
DEMO
Literally added the word multiple
to the select box in order to modify it to fit OP's requirements...
DEMO 2
回答2:
I'm not sure if I understand the question, but I'm almost positive you want to be using this: http://jqueryui.com/tooltip/
来源:https://stackoverflow.com/questions/17818153/how-can-i-add-a-tooltip-in-chosen-jquery-plugin