在游览器控制台copy的总是最后一个的数据

var ListTables = document.getElementsByClassName("listTable")[0];
var opinions = [];
var calls = [];
for(var i = 0, len = ListTables.rows.length; i < len; i++){

if(i == 0){
    var name  =  ListTables.rows[i].cells[0].innerHTML.replace(" - 意见建议", "");
} else{
    var opinion = ListTables.rows[i].cells[0].firstChild.innerHTML;
    opinions.push(opinion);
    var call = ListTables.rows[i].cells[0].lastChild.innerHTML;
    calls.push(call);
}

}
for(var j = 0, len = opinions.length; j < len; j++){

calls[j] = name + "    " + calls[j] + "    " + opinions[j] + "\n"
copy(calls[j]);

}

阅读 1.2k
1 个回答
var ListTables = document.getElementsByClassName("listTable")[0];
var opinions = [];
var calls = [];
for(var i = 0, len = ListTables.rows.length; i < len; i++){

    if(i == 0){
        var name  =  ListTables.rows[i].cells[0].innerHTML.replace(" - 意见建议", "");
    } else{
        var opinion = ListTables.rows[i].cells[0].firstChild.innerHTML;
        opinions.push(opinion);
        var call = ListTables.rows[i].cells[0].lastChild.innerHTML;
        calls.push(call);
    }
}
var str = "";
for(var j = 0, len = opinions.length; j < len; j++){
    str += name + "    " + calls[j] + "    " + opinions[j] + "\n";
}
copy(str);

//自动跳转
var next_page = location.href;
var next_page = next_page.split("=");
next_page[1] = parseInt(next_page[1]);
var num_add = next_page[1]+1;
var next_page_url = next_page[0] + "=" + num_add;
location.href = next_page_url;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题