这些片段可以自动调整单个文本区域的大小:
http://jsfiddle.net/ImpressiveWebs/fGNNT/1333/
例如,在上面的第一个链接中,这是文本区域:
<textarea id="comments" placeholder="Type many lines of texts in here and you will see magic stuff" class="common"></textarea>
并在输入文本时调整大小。
但是,随着
<textarea id="comments" placeholder="Type many lines of texts in here and you will see magic stuff" class="common"></textarea>
<textarea id="comments" placeholder="Type many lines of texts in here and you will see magic stuff" class="common"></textarea>
只有第一个正在调整大小。如何使第二个也要调整大小?
这可以正常使用http://jsfiddle.net/fGNNT/2219/。使用类代替ID进行识别
// Bad
var txt = $('#comments'),
hiddenDiv = $(document.createElement('div')),
content = null;
// Good and working
var txt = $('.common'),
hiddenDiv = $(document.createElement('div')),
content = null;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句