js中怎样遍历table来隐藏行,已知table的id和要隐藏的tr的id,求大神指导啊

2025-04-25 09:25:13
推荐回答(1个)
回答1:

document.getElementById("table_id").children().forEach(function(ele){
    if(this.id == "tr_hide_id") this.style.display = "none";//隐藏
    //if(ele.id == "tr_hide_id") ele.style.display = "none";//这样应该也是可以的
});
//类似这样的代码就可以了,table_id tr_hide_id 改成自己的就可以了