开发者

jquery - find if element is overflowing its container

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜