我正在处理响应式表格,并且希望在与当前日期匹配的情况下将行内容设为粗体。
我将第一个孩子 th 和 td 隐藏起来,因为我只需要它来实现某些功能
基于 <td data-label="TodaysDate">06-05-2020</td>
和的价值<td data-label="Date">05-05-2020</td>
if value if TodaysDate = Date那么我需要将此行设为粗体。
我怎样才能使用javascript做到这一点
https://codepen.io/KGuide/pen/MWwMZzP
function compareCellValues() {
var rows = $(".ramadan-time").find("tbody tr"); //returns all table rows
rows.each(function() { //iterate over each row.
var thisRow = $(this), //this is the current row
TodaysDate = thisRow.find(".TodaysDate"), //this is the first value
sDate = thisRow.find(".Date"); //this is the second value
if (TodaysDate.text() !== sDate.text()) {
thisRow.css("font-weight", "bold");
}
thisRow.find(".TodaysDate").text(parseInt(TodaysDate.text()) - parseInt(sDate.text()));
});
}
window.onload = compareCellValues();
body {
font-family: "Open Sans", sans-serif;
line-height: 1.25;
}
.ramadan-time > thead tr th:first-child{color:red; display:none;}
.ramadan-time > tbody tr td:first-child{color:red; display:none;}
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;
}
table tr {
background-color: #f8f8f8;
border: 1px solid #ddd;
padding: .35em;
}
table th,
table td {
padding: .625em;
text-align: center;
font-size: 12px;
}
table th {
font-size: .85em;
font-size: 12px;
letter-spacing: .1em;
text-transform: uppercase;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
@media screen and (max-width: 380px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border-bottom: 3px solid #ddd;
display: block;
margin-bottom: .625em;
}
table td {
border-bottom: 1px solid #ddd;
display: block;
font-size: .8em;
text-align: right;
}
繁星点点滴滴
相关分类