0
解釋這一點的最佳方法是使用一個例子:是否有可能使用jQuery來確定行高?
<div style="width:100px;height:100px;overflow:hidden;">
<?php echo $content; ?>
</div>
如何使用jQuery來看看是否有文本溢出?
解釋這一點的最佳方法是使用一個例子:是否有可能使用jQuery來確定行高?
<div style="width:100px;height:100px;overflow:hidden;">
<?php echo $content; ?>
</div>
如何使用jQuery來看看是否有文本溢出?
比較元素的scrollHeight
(DOM屬性,因此.get(0)
)和height
,以檢查元素的內容是否超出元素的邊界。
var $div = $("div"); //Assume one div. Use a more specific selector
var isOverflowing = $div.get(0).scrollHeight != $div.height();
//The variable `isOverflowing` is true if the text overflows