当用户调整由CSS3定义的可调整大小的文本输入时,是否可以捕获resize事件? [英] Is it possible to catch resize event when user resizes text input defined resizable by CSS3?

查看:96
本文介绍了当用户调整由CSS3定义的可调整大小的文本输入时,是否可以捕获resize事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文本输入定义为可调整大小使用CSS,像这样:

  #text_input {resize:horizo​​ntal; } 
< input type =textid =text_input/>

当用户调整输入大小时,是否可以抓住Javascript我尝试使用standart jQuery .resize(),但它不工作,因为我想。



感谢任何帮助...

解决方案

您可以使用mouseup事件。尽可能多的我试图调用每次调整大小后。



编辑:


如果您的程式码大小不同,

 < textarea name =blaid =bla>< / textarea> 

$('#bla')。bind('mouseup',function(e){
if($(e.currentTarget).data('lastWidth')!= $ e.currentTarget).width()){
console.log(resize!);
}
$(e.currentTarget).data('lastWidth',$(e。 currentTarget).width());
}); width()仍然返回旧值,至少在chrome



< >

I have text input defined to be resizable using CSS, like this:

#text_input { resize:horizontal; }
<input type="text" id="text_input" />

Is it possible to catch Javascript (preferrably in jQuery) event when the user resizes input ? I've tried using standart jQuery .resize() but it doesn't work as I suppose to.

Thanks for any help...

解决方案

you can use the mouseup event. as much as i tried it's called after every resize. if you do a check if the current size is different then the last size your code isn't even executed to often.

EDIT:

<textarea name="bla" id="bla"></textarea>

$('#bla').bind('mouseup', function(e){
  if($(e.currentTarget).data('lastWidth') != $(e.currentTarget).width()){
    console.log("resize!");
  }
  $(e.currentTarget).data('lastWidth', $(e.currentTarget).width());
});

might be a problem that width() still returns the old value, at least in chrome

这篇关于当用户调整由CSS3定义的可调整大小的文本输入时,是否可以捕获resize事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆