带有文本的鼠标指针“;工具提示”;
Mouse pointer with text "tooltip"
我使用HTML/jquery/CSS,并有一段文本-"test"。
我如何让"测试"文本跟随鼠标指针(或者如果更容易的话,用文本替换鼠标指针图标)?
编辑来自Tims的答案:
CSS: #follower { background: #fff; padding: 5px; border: 1px solid #ddd; position: absolute; }
JS: $(document).ready(function(){
$("#follower").hide();
$(document).mousemove(function(e){
$("#follower").show();
$("#follower").css({
top: (e.pageY + 15) + "px",
left: (e.pageX + 15) + "px"
});
});
});
您可以使用mousemove事件来捕捉鼠标的位置,然后设置为文本span。
Html:
<html>
<body onmousemove="mousemove()">
<span id="textSpan" style="position:absolute">test</span>
</body>
</html>
js:
function mousemove()
{
$('#textSpan').css({
'top' : event.pageY,
'left' : event.pageX
});
}
在JsFiddle 中看到它的作用
<div id="demo-mouse" class="box">
<h3>Hover over this box to see mouse tracking in action</h3>
</div>
$(document).ready(function()
{
$('#demo-mouse').qtip({
content: 'I position myself at the current mouse position',
position: {
my: 'top left',
target: 'mouse',
viewport: $(window), // Keep it on-screen at all times if possible
adjust: {
x: 10, y: 10
}
},
hide: {
fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
},
style: 'ui-tooltip-shadow'
});
});
相关文章:
- 鼠标悬停时的 SVG 工具提示
- Extjs 3.4 中属性网格行值的工具提示 /Qtip(鼠标悬停)
- Flexslider-当鼠标悬停在点上时显示工具提示
- 如何在鼠标位于工具提示上时保持d3鼠标悬停打开
- jQuery:使用插件Tipsy将工具提示附加到鼠标光标位置
- 工具提示-获胜'不要把鼠标藏起来
- 使用 dojo 将鼠标悬停在动态下拉列表选择上时添加工具提示
- 将鼠标悬停事件更改为工具提示的 Onclick 事件
- 如何在 D3 中创建工具提示,以便在图形中节点上的鼠标悬停上获取图像
- 在工具提示中将鼠标悬停时更改背景颜色
- 如何在 extjs 4.2.1 中为鼠标悬停时的行扩展器图标提供工具提示
- D3.JS:带有鼠标悬停工具提示的多折线图
- 需要帮助修改图表.js鼠标悬停工具提示
- 避免工具提示在鼠标悬停时隐藏
- q提示 2 - 鼠标按下以显示工具提示?鼠标向上隐藏
- 带有文本的鼠标指针“;工具提示”;
- jquery中的工具提示鼠标移动问题
- nvd3工具提示位置基于鼠标指针使用JavaScript
- 如何让jQuery鼠标悬停工具提示跟随鼠标指针?
- 如何在鼠标指针位于YUI上下文菜单项上时显示工具提示