我试图检测用户何时调整可调整大小的文本区域的大小..
我试图用这段代码来做到这一点,但它不起作用:
$('textarea.note').bind("resize", function(){
alert("resize!!!!!");
})
我真的不想使用任何类型的计时器和循环..帮助!?
最佳答案
$(document).ready(function () {
var $textareas = jQuery('textarea');
// set init (default) state
$textareas.data('x', $textareas.outerWidth());
$textareas.data('y', $textareas.outerHeight());
$textareas.mouseup(function () {
var $this = $(this);
if ($this.outerWidth() != $this.data('x') || $this.outerHeight() != $this.data('y')) {
alert($this.outerWidth() + ' - ' + $this.data('x') + '\n' + $this.outerHeight() + ' - ' + $this.data('y'));
}
// set new height/width
$this.data('x', $this.outerWidth());
$this.data('y', $this.outerHeight());
});
});
关于jQuery - 检测文本区域大小何时调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18393172/