最佳答案
由于我无法清楚地看到您的完整 DOM,因此我将向您介绍如何迭代这些行并返回带有关联警告的行 -
var allTr = document.getElementsByClassName("classNameOnTr");
Array.prototype.forEach.call(allTr, function(tr) {
// all tds within a tr
var trAllTd = tr.children;
// first td out of all
var firstTd = trAllTd[0];
if(firstTd.children[0]) {
// this is the probable div which creates the warning indicator
// write your logic to check if the div exist here
// break the loop if you find it here and return the td
}
});
注意:
我已经编写了冗长的代码,以便让您更多地了解如何进行操作。如果您理解得很好,可以将其缩短一两行。
关于javascript - 基于条件的动态行选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59517505/