2017-03-22 112 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)中提到的內容:*您也可以指定一個函數返回內容... * –