gpt4 book ai didi

javascript - 单击时突出显示表格行 - 不突出显示第一行

转载 作者:行者123 更新时间:2023-11-28 03:43:08 24 4
gpt4 key购买 nike

我有这个 HTML:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class='panel-heading'>
TV Schedules
</div>
<div class='panel-body'>
<table class='table table-striped table-inverse font_styling table-hover' id='tv_schedule_table'>
<thead>
<tr>
<th class='center_text sorttable' width='25%'>Show Name&nbsp; <span class='fa fa-caret-down'></span> <span class='fa fa-caret-up'></span></th>
<th class='center_text sorttable' width='25%'>Episode&nbsp; <span class='fa fa-caret-down'></span> <span class='fa fa-caret-up'></span></th>
<th class='center_text sorttable'>Date Aired&nbsp; <span class='fa fa-caret-down'></span> <span class='fa fa-caret-up'></span></th>
<th width='10%'></th>
</tr>
</thead>
<tbody>
<tr id='tv_schedule_row'>
<td class='center_text cell_width' width='25%'>{{tv_show.show_name}}</td>
<td class='center_text clickable_cell' width='25%'>{{tv_show.season_episode}}</td>
<td class='center_text clickable_cell' width='20%'>{{tv_show.date_aired}}</td>
<td class='center_text w3-large' width='15%'><i class='fa fa-check icon-styling' style='margin-left:5px; margin-right:5px;'></i> <i class='fa fa-trash icon-styling' style='margin-left:5px; margin-right:5px;'></i> <i class='fa fa-search icon-styling' style='margin-left:5px; margin-right:5px;'></i> <i class='fa fa-plus icon-styling' style='margin-left:5px; margin-right:5px;'></i></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

这是高亮行调用的函数:

$scope.alter_show = function(show, index)
{
$scope.editing_show = true;

var line_no = index+1;
var table = document.getElementById("tv_schedule_table");
var cells = table.getElementsByTagName("tr");

cells[line_no].className = "hover_click_cell selected_click_cell";
}

出于某种原因,这对第一行不起作用,但从第 2 行开始,它就起作用了。我不太确定我哪里出错了。

最佳答案

开始时索引的值是多少?

请记住,“cells”对象的索引为 0,因此第一个“tr”元素将为 tr[0]

关于javascript - 单击时突出显示表格行 - 不突出显示第一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44111273/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com