`find()`undefined不是一个函数 [英] `find()` undefined is not a function
本文介绍了`find()`undefined不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个小jquery函数:
I have this little jquery function:
$.each($('#TableBody tr:gt(0)'), function(index, element){
element.find('td').last().html($('<span/>', {class: "input-group-addon", text: 'Auswählen'}));
});
不知怎的,我在第一行收到此错误:
Somehow i get this error in the first line:
Uncaught TypeError: undefined is not a function
我在控制台中试了一些东西来解决这个问题!但不知何故没有用!
I tried some things in the console to fix this problem! But somehow nothing worked!
现在我希望你能帮助我! JSFIDDLE: http://jsfiddle.net/3C98M/
Now i hope you can help me! JSFIDDLE: http://jsfiddle.net/3C98M/
谢谢
推荐答案
元素
不是jQuery对象, $的第二个参数。每个
函数返回本机DOM节点
element
is not a jQuery object, the second argument of the $.each
function returns the native DOM node
$.each($('#TableBody tr:gt(0)'), function(index, element){
$(element).find('td').last().html($('<span/>', {"class": "input-group-addon", text: 'Auswählen'}));
});
另请注意 class
是保留关键字在javascript中应该引用。
它也可以写成
Also note that class
is a reserved keyword in javascript and should be quoted.
It could also be written
$('#TableBody tr:gt(0)').each(function(index, element) {
$(element).find('td').last().html(
$('<span/>', {
"class" : "input-group-addon",
text : 'Auswählen'
})
);
});
这是更具可读性的IMO。
which is more readable IMO.
这篇关于`find()`undefined不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文