简体   繁体   English

当我将鼠标悬停在下拉列表中的某个项目上时,如何显示JQuery工具提示?

[英]How can I get the JQuery Tooltip to display when I hover over an item on a dropdown list?

The tooltip works for about everything else except drop down items. 工具提示适用于除下拉项目之外的所有其他内容。

What am I doing wrong 我究竟做错了什么

$(document).ready(function(){
    $('option').each(function(){
        $(this).tooltip();
    });
    //$('option').tooltip();
});

edit: my html is pretty basic at the moment http://jsfiddle.net/kasfu/ 编辑:我的HTML目前非常基本http://jsfiddle.net/kasfu/

edit I want the tooltip to show when I hover over an item on the dropdown list 编辑我希望当我将鼠标悬停在下拉列表中的项目上时显示工具提示

By the looks of it, it has nothing to do with your code. 从它的外观来看,它与你的代码无关。 It's a known issue, and one that doesn't look like it will be fixed (any time soon anyway). 这是一个众所周知的问题,看起来不像它的问题(无论如何都会很快)。 The tooltip does work in chrome, however webkit browsers don't like tooltips on option elements. 工具提示在chrome中有效,但webkit浏览器不喜欢option元素上的工具提示。

See here for the bug ticket 请看这里的错误票

I guess you have three solutions that I can think of. 我猜你有三个我能想到的解决方案。

  1. Find a different / Build your own tooltip plugin that does work. 查找其他/构建您自己的工具提示插件,确实有效。

  2. Use a <ul> and style it to look like a drop-down, and add some jQuery to control the show/hide 使用<ul>并将其设置为下拉样式,并添加一些jQuery来控制显示/隐藏

  3. Just stick with the browsers standard tooltip. 只需坚持浏览器标准工具提示即可。

Hope this helps. 希望这可以帮助。

From your tooltip plugin link. 从您的工具提示插件链接。 I guess, it depends on jquery.dimensions.js and jquery.bgiframe.js from the demo page. 我猜,它取决于演示页面中的jquery.dimensions.js and jquery.bgiframe.js

I think I have what you need.. 我想我有你需要的......

<select>
    <option title="1" >1</option>
    <option title="2">2</option>
    <option title="3">3</option>
</select>

$(document).ready(function(){
$('option').each(function(){
        $(this).style.top = window.event.clientY + 20;
        $(this).style.left = window.event.clientX;
        $(this).style.display = 'block';
        $(this).tooltip();
    });
});

Hope this helps. 希望这可以帮助。

I think you should try this 我想你应该试试这个

$('option').each(function(index, element){
        $(element).tooltip({ content: "<div>Select an Item</div>", track: true});
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM