MCPcopy Create free account
hub / github.com/dajie111/nodeseek-userscript / highlightRowCol

Function highlightRowCol

notes.js:259–282  ·  view source on GitHub ↗
(table, targetCell)

Source from the content-addressed store, hash-verified

257
258 // 高亮当前行列
259 function highlightRowCol(table, targetCell) {
260 // 清除之前的高亮
261 table.querySelectorAll('td, th').forEach(cell => {
262 cell.style.backgroundColor = '';
263 });
264
265 const row = targetCell.parentElement;
266 const cellIndex = Array.from(row.children).indexOf(targetCell);
267
268 // 高亮当前行
269 Array.from(row.children).forEach(cell => {
270 cell.style.backgroundColor = '#eff6ff';
271 });
272
273 // 高亮当前列
274 Array.from(table.rows).forEach(r => {
275 if (r.children[cellIndex]) {
276 r.children[cellIndex].style.backgroundColor = '#eff6ff';
277 }
278 });
279
280 // 高亮当前单元格
281 targetCell.style.backgroundColor = '#dbeafe';
282 }
283
284 // 表格操作函数
285 function addRowAbove(table, rowIndex) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected