调整文本区域的事件大小? [英] Resize event for textarea?
问题描述
当前版本的 Firefox 和 Chrome 包含一个拖动处理程序来调整 框的大小.我需要捕获调整大小事件,我认为使用 jQuery 的
resize()
事件会很容易,但它不起作用!
The current versions of Firefox and Chrome include a drag handler to resize a <textarea>
box. I need to capture the resizing event, I thought it would be easy with jQuery's resize()
event, but it doesn't work!
我也试过普通的 onResize
事件,但结果是一样的.您可以在 JSFiddle 上试用.
I have also tried the normal onResize
event, but the result is the same. You can try it on JSFiddle.
有没有办法捕捉它?
推荐答案
在发出 resize 事件之前,您需要先调整 textarea 的大小.您可以通过使用 jQuery UI resizable() 来做到这一点,并在其中调用 resize 事件.
You need to first make the textarea resizable before issuing the resize event. You can do that by using jQuery UI resizable() and inside it you can call the resize event.
$("textarea").resizable({
resize: function() {
$("body").append("<pre>resized!</pre>");
}
});
这篇关于调整文本区域的事件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!