$("#tableEmail td[background-color = dodgerblue]"); background-color为rgb格式,不是dodgerblue
建议你使用class设置背景颜色
你可以这样
<html><head><script src="jquery-1.9.1.min.js"></script></head><body> <table id="tableEmail"> <tr> <td style="background: dodgerblue">sdsd</td> <td style="background: red">sdsd</td> </tr> </table> <input type=button value=test onclick="xx()"> <script> function xx() { alert($('#tableEmail td').css("background-color")) $('#tableEmail td').filter(function() { return $(this).css('background-color') == 'dodgerblue'; }).html("xxxxxxx") } </script></body></html> 你可以这样
var x = $('#tableEmail td').filter(function() {
return $(this).css('background-color') == 'rgb(30, 144, 255)';
})
x.html("xxxxxxx")
x就是那个td
IE中这样写
$('#tableEmail td').filter(function() {
return $(this).css('background-color') == 'dodgerblue';
})
例子
<html><head><script src="jquery-1.9.1.min.js"></script></head><body> <table id="tableEmail"> <tr> <td style="background: dodgerblue">sdsd</td> <td style="background: red">sdsd</td> </tr> </table> <input type=button value=test onclick="xx()"> <script> function xx() { alert($('#tableEmail td').css("background-color")) $('#tableEmail td').filter(function() { return $(this).css('background-color') == 'dodgerblue'; }).html("xxxxxxx") } </script></body></html>var select = td.filter(function () { return $(this).css("background-color") == "rgb(30, 144, 255)" }); 有2个方法
1,使用Color.js,下载使用方法参见name2rgb http://matthewbj.github.io/Colors/
2,使用json预定义
http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
有2个方法
1,使用Color.js,下载使用方法参见name2rgb http://matthewbj.github.io/Colors/
2,使用json预定义
http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
谢谢你,还有就是为什么select.next()得不到下一个单元格?
有2个方法
1,使用Color.js,下载使用方法参见name2rgb http://matthewbj.github.io/Colors/
2,使用json预定义
http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
谢谢你,还有就是为什么select.next()得不到下一个单元格?
我知道为什么了,因为各个td位于不同的tr中,并不是兄弟关系,而我的td都只有1个,所以select.next()为空。正确的做法是select.parent().next().children().first(),先得到父元素tr,然后得到下一个tr,再得到tr所有子元素td,最后得到第一个子元素td即我们看到的下一个单元格了。
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号