使用jquery中的以下代码:
$(source).children('table').filter(function() {
return ($('tbody > tr', 'table').length >= 4)})我筛选出具有4行或更多行的表。我尝试使用map (function() )从这里创建一个html数组,但似乎不起作用。我正在尝试获取满足此条件的每个表的html()。
发布于 2011-06-21 08:19:09
我想这就是你要找的:
$(source).children("table").map(function() {
if ($("tbody > tr", this).length >= 4) {
return $(this).html();
} else {
return null;
}
}).get();jQuery中的Selector context需要DOM元素、jQuery或文档。使用this将查询限制到在filter函数中计算的元素。
发布于 2011-06-21 08:23:22
var htmlArray = $('#source').children('table')
.filter(function() {
return ($('tbody > tr', $(this)).length >= 4);
}).map(function(i, item) {
return $(item).html();
}).get();https://stackoverflow.com/questions/6418937
复制相似问题