mar*_*k12 3 jquery google-chrome
我有以下jQuery代码在Firefox和Internet Explorer中正常工作.它在Chrome中不起作用,我无法弄清楚原因.
我正在尝试background-image使用此代码更改元素:
$(".category-nav").find("a").each(function(index){
if($(this).css("background-color") === "transparent" && !$(this).parent().hasClass("level1"))
{
$(this).css("background-image", "url(/images/gallery/images/arrow-cat-list-grey.png)");
}
});
Run Code Online (Sandbox Code Playgroud)
Chrome返回rgba(0, 0, 0, 0)透明背景颜色(演示)
请尝试使用此代码(演示):
$(".category-nav").find("a").each(function(index){
if ( /transparent|rgba\(0, 0, 0, 0\)/.test($(this).css("background-color") ) &&
!$(this).parent().hasClass("level1") )
{
$(this).css("background-image", "url(/images/gallery/images/arrow-cat-list-grey.png)");
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
212 次 |
| 最近记录: |