调整div元素的大小 [英] Resize on div element
问题描述
jQuery有 resize()
- 事件,但它只适用于窗口。
jQuery has the resize()
- event, but it just work with window.
jQuery(window).resize(function() { /* What ever */ });
这很好用!但是当我想将事件添加到div元素时它不起作用。
This works fine! But when I want to add the event to a div element it doesn't work.
例如
jQuery('div').resize(function() { /* What ever */ });
我想在div元素的大小发生变化时开始回调。我不想开始一个可调整大小的事件 - 只是一个事件来检查div -
元素的大小是否已经改变。
I want to start an callback when the size of a div-element has changed. I don't want to start a resizable - event – just a event to check if the size of a div - element has changed.
有没有这样做的解决方案?
Is there any solution to do this?
推荐答案
DIV
不会触发调整大小
事件,因此您将无法完全按照您的编码进行操作,但您可以查看监控DOM属性。
DIV
does not fire a resize
event, so you won't be able to do exactly what you've coded, but you could look into monitoring DOM properties.
如果你实际上正在处理像resizables这样的东西,那么div是改变大小的唯一方法,那么你的resize插件可能会实现自己的回调。
If you are actually working with something like resizables, and that is the only way for a div to change in size, then your resize plugin will probably be implementing a callback of its own.
这篇关于调整div元素的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!