【发布时间】:2020-04-18 09:54:43
【问题描述】:
【问题讨论】:
-
我已经编写了一个帮助代码来了解您如何去做。如果您有不明白的地方,请告诉我。
标签: javascript dom dynamic dom-manipulation
【问题讨论】:
标签: javascript dom dynamic dom-manipulation
由于我无法清楚地看到您的完整 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
}
});
Note:我写了很长的代码来让你更清楚如何去做。如果你理解得很好,你可以将它缩短一两行。
【讨论】: