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
。这没有内置事件。