2017-03-22 23 views
0

我想使用qtip jquery插件来显示悬停元素的完整值。可以qtip显示当前悬停元素的值

原因是输入字段太短,无法显示整个字符串,所以我想在悬停时显示它。

当我尝试我的代码时,显示qtip“盒子”,但没有内容。

HTML

<input type="text" class="desc" value="this is a long string of text that doesn't all show on the page"> 

CSS

.desc{ 
    width:80px; 
} 

的JavaScript

$('.desc').qtip({ 
    content: { 
    text: function(event, api) { 
     $(this).val(); 
    } 
    } 
}); 

jsFiddle

回答

0

的解决方案是 “回归” 的价值

$('.desc').qtip({ 
    content: { 
    text: function(event, api) { 
     return $(this).val(); 
    } 
    } 
}); 
+0

...在[文档](http://qtip2.com/options#content.text)中提到的内容:*您也可以指定一个函数返回内容... * –