简体   繁体   English

Internet Explorer和Firefox中的jQuery自动调整大小问题

[英]jQuery autosize issue in Internet Explorer and Firefox

I am very new to jQuery and JS. 我对jQuery和JS非常陌生。 Recently i have been assigned to a bug, in which textarea should resize on focus according to the text present into that textarea. 最近,我被分配到一个错误,该错误中文本区域应根据该文本区域中显示的文本调整焦点的大小。
We have used $('textarea').autosize(); 我们使用了$('textarea').autosize(); function in a JS file. JS文件中的功能。
This works properly on recent FF versions and latest IEs (9+), but it's not working on IE 7 and FF 3.5.3 这在最新的FF版本和最新的IE(9+)上正常运行,但在IE 7和FF 3.5.3上不起作用

I found this , but didn't workout. 我找到 ,但是没有锻炼。

The easiest could be that on the focus event of the textarea , u could populate the current text of the textarea to another span which is hidden in the view and has the same text styles as the textarea. 最简单的可能是在focus event of the textarea ,ü可以填充textarea的当前文本到其它span是隐藏在视图中,并具有相同的文本样式的文本区域。

Once this new span has the text, u can get its width and height and then assign these to the textarea. 一旦此新跨度包含文本,您就可以获取其width and height ,然后将其分配给文本区域。 Since these are very primitive actions, they must work in IE7 and FF3 由于这些动作非常原始,因此必须在IE7和FF3中运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM