2
私はタイムテーブルであるテーブルを持っています。 私がしたいのは、2つ以上の同じタスクがお互いに行き来して境界線が来る場合です。 (これは私がやった)。また、私はテキストをテーブルの中央に配置したい。中央のテキストを水平方向に複数回出力テーブル
参照例の明確化のために
https://jsfiddle.net/79bs6Lhb/3/
var tds = document.querySelectorAll("td")
for (var o = 0; o < tds.length; o++) {
if ($(tds[o]).next().html() === $(tds[o]).html() && $(tds[o]).prev().html() === $(tds[o]).html()) {
$(tds[o]).css("borderRight", "none");
$(tds[o]).css("borderLeft", "none");
} else if ($(tds[o]).next().html() === $(tds[o]).html()) {
$(tds[o]).css("borderRight", "none");
} else if ($(tds[o]).prev().html() === $(tds[o]).html()) {
$(tds[o]).css("borderLeft", "none");
}
}
table {
border-collapse: collapse;
}
td {
border: 2px solid grey;
padding: 25px;
text-align: center;
}
th {
border: 2px solid grey;
padding: 25px;
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<thead>
<tr>
<th>1:00</th>
<th>2:00</th>
<th>3:00</th>
<th>4:00</th>
<th>5:00</th>
<th>6:00</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sleep</td>//Should Only be one "Sleep" and it should be centered through all the "Sleep td"
<td>Sleep</td>
<td>Sleep</td>
<td>Sleep</td>
<td>Sleep</td>
<td>Wake Up</td>
</tr>
</tbody>
</table>
あなたは、私は強くあなたの機能であなたのインクリメンタOとして使用しないことをお勧めします 'colspan' – Jecoms
を探しています - 後で(またはSOで)それを読むことがwayyyyyあまりにも簡単にゼロとして - すなわち、:tds [o]とtds [0] - それを並べて見ると明らかですが、コンテキストから読み込んだりデバッグしようとすると、tds [o]を見て、参照するのが簡単です(すなわち、インデックス[0])。ちょうど私の0pinion。 ....私がそこに行ったものを見る:) – gavgrif