gpt4 book ai didi

jQuery:更改背景颜色的简单 .css 行在 Chrome 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 13:38:05 25 4
gpt4 key购买 nike

我使用以下行有条件地更改 TD 的背景颜色。这在 IE 和 Firefox 中运行良好,但在 Chrome 中它根本不设置任何颜色。

我也尝试使用 rgb(255, 255, 0) 代替,但 Chrome 的结果相同,使用的版本是 33.0.1750.154 m,这似乎是最新版本。

有没有办法让它在所有三种浏览器中都能正常工作?

我的代码片段:

$('.search').click(function() {
var value = $(this).text();
var color = $(this).css('background-color');
if(color == 'transparent') {
$('td')
.css('background-color', '')
.filter(function(){
return $(this).text() === value;
})
.css('background-color', 'yellow');
//...

提前致谢,蒂姆。

最佳答案

如果可以,首先检查是否发生任何错误,你可以查看控制台..如果没有发现错误,请在检查以蓝色选择元素时检查 css 选择器 ...如果不是,请尝试设置宽度和高度。如果现在,请尝试设置溢出:隐藏,..如果仍然有问题,请尝试在 css 文件中设置 bg 颜色和类,如果工作正常,您可以尝试像这样添加类

.testColor{
background-color: yellow;
}

jQuery(".myClass").addClass("testColor");

祝你好运

关于jQuery:更改背景颜色的简单 .css 行在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22885793/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com