Using Jquery, how to I find out if an element is overflowing its container ?
<div style="overflow:hidden"><label>My really really long label</label></div>
I would like to know when the 开发者_运维百科text of the label is being cutoff so that I can act on it.
Thank you
You could use the width function to check if the <label>
is longer than the <div>
:
if($('label').width() > $('div').width()){
// longer element
}
Here's a simple example.
精彩评论