默认情况下,文本区域应为空。 但是当我
alert($("#mytextarea").val())
...值为:
111
111
我正在使用 Jquery Growfield 插件:http://plugins.jquery.com/project/Growfield
我这样做:
$("#id_comment_body").growfield({animate:0});
最佳答案
哦哦哦哦哦我打赌我知道这是怎么回事!!!检查该插件的文档:
To correctly resize the textarea without flickering or strange behavior to the user, we do the calculations in a dummy invisible text area. The text area is created during focus and removed afterwards. Be careful as the dummy contains the same id and name as the original element so when you do javascript while the user has focus, make sure to not use the element with the class 'growfieldDummy'. If you need to manipulate the growfield text area, do it when the user will not have focus (a user clicks on something to initiate an action to do whatever to the textarea, or during $(document).ready.
我敢打赌,当您执行 $('#mytextarea')
时获得的元素是克隆的!尝试按照该文档所述操作:
alert($('#mytextarea:not(.growfieldDummy)').val());
关于javascript - 为什么 JQuery Growfield 插件为我的文本区域提供默认值 "111 111"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4466151/