3
是否有一個跨瀏覽器的方式來聽DIV溢出?
喜歡的東西:$('#myDiv').bind("divOverflow", function(){alert('div overflowed!')})
是否有一個跨瀏覽器的方式來聽DIV溢出?
喜歡的東西:$('#myDiv').bind("divOverflow", function(){alert('div overflowed!')})
你可以做到這一點的scrollHeight屬性與clientHeight比較。
<script type="text/javascript">
function GetContainerSize()
{
var container = document.getElementById ("tempDiv");
var message = "The width of the contents with padding: " + container.scrollWidth + "px.\n";
message += "The height of the contents with padding: " + container.scrollHeight + "px.\n";
alert (message);
}
</script>
你可以設置的時間間隔,並檢查元素的scrollHeight > offsetHeight
。這沒有內置事件。