欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

jQuery找到指定背景颜色的td_html/css_WEB-ITnose

程序员文章站 2022-05-28 17:16:30
...
怎么找到指定颜色的td表格
----
$("#hutNew").find("td").each(function () {                    if ($(this).attr('style') == 'background:rgb(34, 139, 34)') {                        $(this).css({ "width": "140px", "cursor": "pointer" });                    } else if ($(this).attr('style') == 'background:none') {                        $(this).css("background", "rgb(85, 85, 85)");                    }                });

-------
这个方法不好使啊
---


回复讨论(解决方案)

定义cssclass用class来找

定义cssclass用class来找

具体说一下

.backcolor{background:rgb(34, 139, 34)}

if($(this).attr('class')=="backcolor"){//}

.backcolor{background:rgb(34, 139, 34)}

if($(this).attr('class')=="backcolor"){//}


多钟颜色的背景 是不是要定义多个class

.backcolor{background:rgb(34, 139, 34)}

if($(this).attr('class')=="backcolor"){//}
好吧 试过了 不行
我要实现多次点击一个Td 然后两种颜色不停的变化 记录下最后一次点击的改变后的颜色 class 好像 只能点击一次


.backcolor{background:rgb(34, 139, 34)}

if($(this).attr('class')=="backcolor"){//}


多钟颜色的背景 是不是要定义多个class
keyile