javascript - 基于条件的动态行选择
解决方案
由于我无法清楚地看到您的完整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:
我已经编写了冗长的代码,让您更了解如何去做。如果你理解得很好,你可以把它缩短一两行。
推荐阅读
- firebase - React Native + Firebase 云功能:保持用户登录?
- vba - PowerPoint vba BeforeSaveAs
- python - Python logging - 过滤所有记录器的日志消息
- ios - 如何将视频从智能手机 (iOS) 应用程序投射到 Smart-TV (Samsung)?
- python - 在python中使用正则表达式在5位数字前插入换行符
- javascript - 如何使用摩卡、柴和量角器睡 10 秒
- c# - System.Text.Json.JsonSerializer 可以在只读属性上序列化集合吗?
- c# - 如何调用默认方法而不是具体实现
- c# - 如何通过jsonconvert序列化不同的对象级别
- regex - 无法使用 Ansible 正则表达式打印匹配字符串的行