javascript - JS: Check if text is exceeding container width -



javascript - JS: Check if text is exceeding container width -

is there js or jquery function observe if innerhtml or text within # of pixels beingness clipped container?

i need few hundred elements on page, performance bit important.

example - determine if text in <td> within 5px of exceeding width:

<td class="cell"> 12,3423 </td> .cell { width: 20px; }

try

$.fn.textwidth = function(){ var html_org = $(this).html(); var html_calc = '<span>' + html_org + '</span>'; $(this).html(html_calc); var width = $(this).find('span:first').width(); $(this).html(html_org); homecoming width; }; $(function(){ alert($('.cell').textwidth()); });

fiddle http://jsfiddle.net/hpyay/

it can possible duplicate (and above code copied from) of calculating text width jquery

javascript jquery html css dom

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -