javascript - jQuery addClass() 方法
问题描述
我正在尝试通过更新其 CSS 类来突出显示具有特定项目 ID(在第一列中)的表行,但它不起作用:
.inactive {
background-color: "red";
}
每当发生特定事件时,我的代码都会调用以下 JavaScript 函数:
function highlight_item(item_id){
var tableRow = $("#itemsTable tr td:first-child").filter(function() {
return $(this).text() == item_id
}).parent();
tableRow.addClass("inactive")
}
奇怪的是,如果我addClass()
用
tableRow.css("backgroundColor", "red")
我在这里做错了什么?
解决方案
从“红色”中删除引号。采用.inactive { background-color: red; }
推荐阅读
- java - 创建名为“passwordEncoder”的 bean 时出错:请求的 bean 当前正在创建中
- postgresql - 在 PostgreSQL 中将列的数据类型更改为整数(带有 n/a 的列)
- c - Lua如何将用户数据从元表__index放入C闭包?
- javascript - 在 Dropzone JS 中选择文件后立即更新 UI
- python - 是否有任何函数可以将 python 代码转换为 MIPS?
- cookies - 为什么每个网站编码人员都不使用 DNT?
- python-3.x - TFS REST API System.IterationPath 返回错误
- c# - 请求中的重定向 URI https://localhost:44322/domain.com 与授权给 OAuth 客户端的 URI 不匹配
- vue.js - Vue 监视待处理的 http 请求
- c# - DirectoryInfo.EnumerateDirectories 仅可访问的文件夹和未隐藏的文件夹