html:
<div id='wrapper'>
<div id='settings'>Settings'</div>
<div id='menu'>
Jobname <input type=text id='tipjob' title='this text should go into the tooltip' length='20'>
Appname <input type=text id='tipapp' title='this text should as app text in the tooltip' length='20'>
</div>
<div id="build">Builds
<div id="build-log">Build Log</div>
</div>
<div id="content">Content
<div id="tooltips">Tooltip</div>
</div>
<div id='footer'>Footer</div>
</div>
JavaScript:
$(document).ready(function(){
$('#tipjob').bind('mouseenter', function() {
$('#tooltips').fadeIn();
});
$('#tipjob').bind('mouseleave', function() {
$('#tooltips').fadeOut();
});
});
也可以在 jsfiddle 上查看 css。
http://jsfiddle.net/yZZDd/433/
在上面的示例(不起作用)中,我希望当一个人将鼠标悬停在输入字段上时能够淡入/淡出一些文本。文本应该进入 div“工具提示”,它现在隐藏在 css 中(也许不是最好的方法)
除了默认的 jquery 之外,我不需要任何其他工具提示库(因为关于工具提示,我认为不需要它)
所以我假设我在每个输入字段中使用 mouseenter/mouseleave,然后设置淡入淡出,但我不知道如何以某种方式将输入字段中的文本放入其中。
由于我从 1 个输入字段开始,我可以只显示和隐藏 div,但这成为第二个输入字段的问题:)
希望我解释正确。这里是第一个计时器。
最佳答案
试试这个 - DEMO
$(document).ready(function(){
$('input').on({
mouseenter: function() {
$('#tooltips').text( $(this).prop("title") ).stop(1, 1).fadeIn();
},
mouseleave: function() {
$('#tooltips').fadeOut();
}
});
});
关于javascript - 通过 jquery 使用输入标题作为 div 的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14032510/