У меня есть таблица, сгенерированная с помощью AngularJS .
Вот мой HTML-код:
<table class="my_table">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Celphone</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="contact in contacts">
<td>{{contact.Name}}</td>
<td>{{contact.Address}}</td>
<td>{{contact.Celphone}}</td>
</tr>
</tbody>
</table>
Я хочу, чтобы каждая строка меняла цвет при «наведении» и другой цвет при «нажал ", поэтому я попробовал это с помощью CSS:
<style>
.my_table tbody tr:hover {
background-color: #7fccee; /*--- this is a blue color when hover ---*/
}
.my_table tbody tr:focus {
background-color: #f3f3f3; /*--- this is a gray color when clicked---*/
}
</style>
Наведение работает идеально, но Focus не работает!(Странно то, что в консоли браузера, если я выбираю строку и « состояние элемента силы: focus », тогда он применяет фокус к строке)
Я также попытался использоватьСЦЕНАРИЙ с jquery:
$(document).ready(function() {
$('.my_table tbody tr').click(function() {
$(this).addClass('active'); //I'm adding the color gray with css to '.active'
});
});
Но это тоже не сработает, что я делаю не так?