当鼠标指向该文本时,我需要更改表格列中数据(文本)的颜色。我不需要更改表格第一列中的颜色。 我实现了以下代码。但它不能正常工作。
onmouseover="{{$index==0?this.style.color='black':this.style.color='#f06751'}}"
onmouseout="this.style.color='black'"
我正在使用 angualr js。
最佳答案
<td ng-style="myColour" ng-mouseenter="ng-mouseenter="changeColor(index,true)""></td>
Controller.js
$scope.changeColor = function(index,bool) {
if(bool === true) {
$scope.myColour = {color: '#c5c2c2'};
} else if (bool === false) {
$scope.myColour = {color: 'white'}; //or, whatever the original color is
}
关于html - 如何设置鼠标悬停功能的if else条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47974479/