开发者

jquery - find if element is overflowing its container

开发者 https://www.devze.com 2023-04-12 05:23 出处:网络
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>

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

精彩评论

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