<分区>
我试图在特定行上突出显示一行。我不得不使用鼠标悬停。
但这对我来说并没有发生。
这是cshtml中的表格定义。
<table class="table">
<thead>
<tr>
<th class="severityCheck"><input type="checkbox" value="" /></th>
<th>Customer Name</th>
<th>Site Name</th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach:CustomerList">
<tr onclick="removepage();" onmouseover="changeRowColor(this)">
<td>
<input class="checkbox" data-bind="attr: { Id: 'checkbox' + $data.Id },click:$parent.customerClick" type="checkbox">
</td>
<td class="col-md-4">
<span class="name" data-bind="text:customerName" />
</td>
<td>
<span data-bind="text:siteName" />
</td>
</tr>
</tbody>
</table>
为了突出显示鼠标悬停,我将 changeRowColor 写为:
function changeRowColor(row) {
row.addClass = 'active';
}
但是这个类并没有被反射(reflect)出来。但是当我这样做的时候
row.style.backgroundColor= 'red';
它正在发生。
我做错了什么?
此外,我必须仅在鼠标位于其上时突出显示当前行,而在鼠标离开时不突出显示。
我该怎么做?