Pur*_*oxy -1 javascript jquery html-table
我正在尝试使用jQuery解析表并填充数组,我已编写此代码来执行此操作:
var comments = new Array();
$("#mytable tr:nth-child(odd)").each( function( index ) {
comments[index]["url"] = $(this).find(".menu2 a").attr("href");
comments[index]["name"] = $(this).find(".menu2 a").text();
comments[index]["avatar"] = $(this).find(".menu2 a img").attr("src");
comments[index]["date"] = $(this).find("td[valign] b:first-child").text();
$(this).find("td[valign] b:first-child").remove();
comments[index]["report"] = $(this).find("td[valign] .pcomment_report").attr("data-refid");
$(this).find("td[valign] .pcomment_report").remove();
comments[index]["comment"] = $(this).find("td[valign]").html();
});
Run Code Online (Sandbox Code Playgroud)
但它让我回报:
TypeError:无法设置undefined的属性'url'
如何使此代码有效?
| 归档时间: |
|
| 查看次数: |
34 次 |
| 最近记录: |