仅在省略号有效时显示工具提示 [英] show the tooltip only when ellipsis is active
本文介绍了仅在省略号有效时显示工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下一个div:
<div class="div-class" style="width:158px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;" title=<%=myDesc%>
仅当省略号有效时,如何显示工具提示?
How can I show the tooltip only when ellipsis is active?
我找到了这个函数
function isEllipsisActive(e) {
return (e.offsetWidth < e.scrollWidth);
}
但是我不知道如何使用它,因为我使用了jsp和struts
But I didn't know how to use it knowing I use jsp and struts
推荐答案
尝试如下操作:
Working DEMO
Working DEMO - with tooltip
$(function() {
$('div').each(function(i) {
if (isEllipsisActive(this))
//Enable tooltip
else
//Disable tooltip
});
});
function isEllipsisActive(e) {
return (e.offsetWidth < e.scrollWidth);
}
这篇关于仅在省略号有效时显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文