$("#tableEmail td[background-color = dodgerblue]");但是就是没有结果。其它的几个属性也用了,如:bgColor,background和backgroundColor,但还是不行,不知道为什么,用filter或not也不行。谁知道怎么写?程序逻辑应该没问题的。另外说一下上面几个背景色的应用场合和区别,我觉得还是不要混用为好。 background-color为rgb格式,不是dodgerblue
建议你使用class设置背景颜色
你可以这样
script>
| sdsd | sdsd |
你可以这样
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';
})
例子
script>
| sdsd | sdsd |
var select = td.filter(function () { return $(this).css("background-color") == "rgb(30, 144, 255)" }); 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
有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即我们看到的下一个单元格了。
Copyright © 2019- axer.cn 版权所有 湘ICP备2023022495号-12
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务