0

我试图遵循这个例子

var tags = $('#MainContent_myTable tr').each(function () {
return $(this).find('.tablecellname').html();
}).get().join(',');
console.log(tags);

当我查看输出时,我得到以下信息:

[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement],  
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement], 
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement],
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement],  
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement],
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement], 
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement], 
[object HTMLTableRowElement],[object HTMLTableRowElement],[object HTMLTableRowElement],...

我做错了什么?

4

1 回答 1

3

您正在使用each()而不是map()

var tags = $('#MainContent_myTable tr').map(function () {
    return $(this).find('.tablecellname').html();
}).get().join(',');
console.log(tags);
于 2013-09-05T15:51:02.160 回答