javascript - 为什么 JQuery Growfield 插件为我的文本区域提供默认值 "111 111"?

标签 javascript jquery html css templates

默认情况下,文本区域应为空。 但是当我

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/

相关文章:

javascript - 调用函数时变量不改变

javascript - 更新键和值 - json 对象

javascript - javascript 中的闭包,对 sum 函数进行多次空调用

javascript - 谷歌地图不显示部分 View ?

javascript - 如何在 HTML 页面上实时动态显示多个行框上标题框中的文本?

jquery - 无需刷新即可更改网页内容

javascript - 警报()和确认()没有显示在iframe的父级上

javascript - 根据下拉菜单创建开关

javascript - Wtf IE7 - 使用 setTimeout 的 AJAX 调用

javascript - 由外部 DIV 控制的可滚动 DIV(用于触摸屏)。 jQuery HTML5