html - 如何设置鼠标悬停功能的if else条件

标签 html css angularjs angular-cli

当鼠标指向该文本时,我需要更改表格列中数据(文本)的颜色。我不需要更改表格第一列中的颜色。 我实现了以下代码。但它不能正常工作。

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/

相关文章:

javascript - 使用jQuery点击元素触发css :active

javascript - 在下一行中插入新磁贴

css - 如何设置 Bootstrap 响应表中列的大小

javascript - Jquery 函数也应该与其他元素一起工作

javascript - "Uncaught RefereceError: txtfile is not defined"

css - Ektron - register.css 似乎破坏了响应式布局

html - 停止列表中的文本换行

javascript - 在 Controller 中调用 AngularJS 服务函数时出错?

javascript - 如果元素未定义则应用类 - AngularJS

javascript - AngularJS REST POST 多个参数