我试着编辑一个网站的CSS,我每天都在使用GreaseMonkey
我想用jQuery来实现这是我的代码:
$(document).ready(function() {
$(".item-name").each(function() {
if ($(".item-name").text() == 'Chair' && $(".item-weight").text() >= 20.0 ) {
$(this) .css("font-weight", "bold")
.css("background-color", "red");
}
else {
$(this) .css("font-weight", "normal");
}
})
});
有两个类名是我的目标。我正在尝试获取.item name匹配的时间,.item weight是该值的>=以触发该单元格变为红色。
我真的是个新手,如果这个问题没有任何意义,我会道歉的。
<div class="col-xs-12">
<table class="table table-striped table-responsive">
<thead>
<tr>
<td colspan="8" class="room-report-heading-td">
<div class="room-report-heading">
<div class="each-room pull-left">
<span class="room-number">1.</span>
<span class="room-name">Room</span>
</div>
<div class="each-room-statistics pull-right">
<span class="room-stat">
1 items
â¢
5.0ft<sup>3</sup>
â¢
20.0lb
</span>
</div>
<br style="clear:both;">
</div>
</td>
</tr>
<tr class="columns-headings">
<th class="item-count">Count</th>
<th class="item-name">Name</th>
<th class="item-volume">Volume</th>
<th class="item-total-volume">Total Volume</th>
<th class="item-weight">Weight</th>
<th class="item-total-weight">Total weight</th>
</tr>
</thead>
<tbody>
<tr>
<td class="item-count"><span>1</span></td>
<td class="item-name"><span>Chair</span></td>
<td class="item-volume"><span>5.0</span></td>
<td class="item-total-volume"><span>5.0</span></td>
<td class="item-weight"><span>20.0</span></td>
<td class="item-total-weight"><span>20.0</span></td>
</tr>
</tbody>
</table>