如何在jQuery中使用工具提示
How to use tooltip with jQuery?
我有一个简单的工具提示,在div中有很长的JavaScript代码。我想让它尽可能简单。
这是我的代码:
<div onmouseover="document.getElementById('tt1DX1').style.display='block'" onmouseout="document.getElementById('tt1DX1').style.display='none'" style="position:relative;">Tool
<div id="tt1DX1" class="toolTip_new pbc11_ttpos1_1Q_di" style="display: none;">
<div class="tool_wrapper">
<div class="tooltip_top_new"></div>
<div class="tooltip_middle_new">
<div class="content">
<p>Please holder actuall text</p>
<p>Please holder actuall text</p>
</div>
</div>
<div class="tooltip_bot_new2"></div>
</div>
</div>
</div>
css
.tooltip_top_new{
background:url(../images/n_tooltip_top.png) no-repeat;
height:9px;
width:212px;
}
.tooltip_middle_new{
background:url(../images/n_tooltip_middle.png) no-repeat;
width:212px;
}
.tooltip_middle_new .content{
padding:2px 13px 1px;
}
.tooltip_middle_new .content p{
line-height: 1.3;
margin-bottom: 1em;
text-align: left;
}
.tooltip_bot_new2{
background:url(../images/n_tooltip_bot2.png) no-repeat;
height:21px;
width:212px;
}
.Question_di{
position:relative;
}
.pbc11_ttpos1_1Q_di {
border: 0 solid #FF0000;
}
.toolTip_new {
background: none repeat scroll 0 0 transparent;
color: #5C5C5C;
display: none;
font: 10px/12px Tahoma,Geneva,sans-serif;
left: -173px;
top: -90px;
position: absolute;
z-index: 1000;
}
问题是,我必须复制&将onmouseover="document.getElementById('tt1DX1').style.display='block'" onmouseout="document.getElementById('tt1DX1').style.display='none'"
粘贴到我使用工具提示的任何位置,我都希望避免它。
http://jquerytools.org/demos/tooltip/index.html
也可以在完全没有JavaScript的情况下创建工具提示,使用HTML和CSS如下:
<div class="has-tooltip">
<button class="huge red">You Know You Wanna...</button>
<div class="tooltip">Do NOT Press This Button.</div>
</div>
在CSS中:
.has-tooltip .tooltip {
position: absolute;
display: none;
<style code to position (with margin-left and margin-top)
and make the tooltip box look how you want>
}
.has-tooltip:hover .tooltip {
display: block;
}
谷歌"CSS工具提示"可以看到很多例子。
相关文章:
- "工具提示"jQuery插件坏了
- 如何在jQuery点击函数中添加并显示引导工具提示
- 我可以't使用jQuery更改工具提示引导程序的位置
- jQuery UI工具提示:单击工具提示本身即可关闭
- 带有关闭按钮的javascript/jquery响应工具提示
- 如何在函数内部为jquery工具提示调用不同的var字符串
- Jquery TOOLS库-工具提示
- 如何使用jquery在工具提示上显示pdf文件
- jQuery UI 工具提示位置的奇怪行为
- 使用 jQuery 工具提示插件获取 clientX
- Jquery 工具提示未随 AJAX 数据加载一起显示
- 悬停工具提示显示详细信息 jquery
- jquery UI工具提示的自定义背景图像
- 带有jQuery的维基百科风格工具提示
- 使用JQuery工具提示基于属性的工具提示
- Jquery工具提示不起作用
- 图像地图中的纯CSS数据工具提示(jquery?)
- HTML工具提示jQuery CSS
- 工具提示 jQuery 始终存在
- 工具提示 jQuery 显示在幻灯片元素之外