可以qtip显示当前悬停元素的值

时间:2017-03-22 19:38:47

标签: jquery qtip2

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

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

当我尝试使用我的代码时,会显示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

1 个答案:

答案 0 :(得分:0)

解决方案是“返回”值

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