Reputation: 245
Im trying to write plugin truncating text to only one line, and give user ability to expand text, i tested lots of them but i dont find suitable for me , to slow, problems if jquery is not loaded etc.
I done this in following way 1. initial span Very Long text w300 - means width 300
$('.trunc').oneLine();
plugin create > Very Long text [+]
css .trunc {overflow:hidden !important; white-space:nowrap !important; display:inline-block;}
PROBLEM i see expand sign[+] in every block, i want to see this only if text overflows block width I don't know how to determine if text is overflowing block. For example part of text is hidden.
Regards wicherqm
Upvotes: 2
Views: 1312
Reputation: 30135
is this what you're looking for?
http://jsfiddle.net/jjTcL/
fiddle code:
$(function() {
var $d = $('<div/>');
$('div').wrapInner($d);
alert($('div div')[0].scrollWidth);
});
Upvotes: 1