[英]How can I use find with each element in jQuery
I want to get all table elements then search for elements in each table.我想获取所有表元素,然后在每个表中搜索元素。
var tbody = $('table')
tbody.each(function(table) {
var elementsArray = table.find('sometext"'); // doesn't work
})
Here it says这里说
Uncaught TypeError: table.find is not a function未捕获的类型错误:table.find 不是 function
How can I use find
like this?我怎样才能像这样使用find
?
.find is a jquery method so you have to use it for a jquery selector like $(selector).find
and also you have a syntax error in .find('sometext"')
you have to change it like .find('sometext')
.find 是一种 jquery 方法,因此您必须将它用于$(selector).find
类的 jquery 选择器,并且.find('sometext"')
中存在语法错误,您必须将其更改为.find('sometext')
var tbody = $('table')
tbody.each(function(index, table) {
var elementsArray = $(table).find('sometext'); // should work
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.