【发布时间】:2013-10-17 09:35:33
【问题描述】:
我正在使用 Jquery Elastic。它适用于 Firefox,但在 chrome 中失败。我只有一个 textarea 我正在使用它。
HTML:
<textarea id = "tarea">Lorem Ipsum</textarea>
将textarea与插件函数绑定:
$(document).load(function() { $('#tarea').elastic() ; }) ;
我打开插件文件,通过alert语句找到chrome中执行停止的地方:
--- code above this initializing arrays, works fine in both FF and chrome
return this.each( function() {
-- Chrome does not execute anything in the callback
// Elastic only works on textareas
if ( this.type !== 'textarea' ) {
return false;
}
.
.
.
}
--- return ends here , chrome does not execute anything here either.
我用 firebug 检查了 JS 的错误,但什么也没找到。我也有一个类似的 chrome 插件,甚至没有报告任何 javascript 错误。
更新:
我将对 plug 的调用从 'load' 事件更改为 'ready' 事件。它现在有效。我不明白为什么。
【问题讨论】:
-
你可以设置一个小提琴
-
如果它在回调中没有得到任何东西,因为在'
this'到'each'中没有任何东西,在.each(),alert( this.length );行之前并检查this是否是绝对是typeof jQuery对象,否则您可能需要重新包装它,jQuery(this)。 -
this是一个 DOM 节点(它没有属性type),因此一旦对'textarea'的检查失败,函数就会返回那里? -
@tobi 不去回调。永远不会执行检查。 @麦基警报(this.length);返回 0。typeof 返回“对象”。我也用 jquery 包装了它,但它没有帮助。
-
问题已更新。请检查。
标签: javascript jquery google-chrome autogrow