【发布时间】:2017-11-11 18:46:47
【问题描述】:
我有一个表格,其中包含如下所示的单元格:
<tr class="dataRow odd">
<td class="actionColumn"> someAction </td>
<th class=" dataCell booleanColumn" scope="row">
<img class="checkImg" width="21" height="16" title="Not Checked"
alt="Not Checked" src="/img/checkbox_unchecked.gif">
</img>
</th>
<td class=" dataCell "> SomeData </td>
</tr>
中间的<th> 单元格将有一个带有title="Not Checked" 或title="Checked" 的图像。
如果title="Not Checked",我想对整行应用一些格式。但是,我是 Greasemonkey 和 javascript 和 CSS 的新手。
我找到了this similar question,但我不完全确定如何调整它。这看起来很接近,但不太正确,我不完全确定如何简单地更改行的 FG/BG 颜色。
var targetLinks = $("tr *dataRow*");
//--- Loop through the links and rewrite images that are in the same row.
targetLinks.each ( function () {
//--- This next assumes that the link is a direct child of tr > td.
var thisRow = $(this).parent ().parent ();
//--- This may need tuning based on information not provided!
var image = thisRow.find ("img");
//--- Replace all target images in the current row.
if ("Not Checked" == image.attr ('title')) {
//Apply Some formatting to thisRow
}
);
}
指针将不胜感激!
【问题讨论】:
标签: javascript html css html-table greasemonkey