我不断变得不确定是不是一个功能 [英] I keep getting undefined is not a function
本文介绍了我不断变得不确定是不是一个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var eaclink = $('a.topLink'),
eacwrap = $('div.pan_inner');
for(var i = 0; i < eaclink.length; i++) {
eacwrap[i].wrap('<div class="panel panel-default"><div id="collapse1" class="panel-collapse collapse in"><div class="panel-body"></div></div></div>');
eaclink[i].attr("data-toggle", "collapse").attr("data-parent", "#accordion").attr("href", "collapse1");
}
我怎么知道未定义的功能?
How do I know whats the undefined function?
推荐答案
wrap
和attr
都不是函数,因为您正在操作DOM元素而不是jQuery对象.
Both wrap
and attr
will be not a function because you're operating on a DOM element instead of a jQuery object.
使用.eq(i)
而不是[i]
来获取用jQuery对象包装的元素.
Use .eq(i)
instead of [i]
to fetch the element wrapped with a jQuery object.
示例:
eacwrap.eq(1).wrap()
这篇关于我不断变得不确定是不是一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文