:has()jquery无法正常工作
我正在尝试在我的网站上执行以下操作:
$(".post-index:has(.wp-post-image)").css("background", "#000");
Js小提琴示例工作正常: http : //jsfiddle.net/rami2929/4x4t9/
但它在我的演示网站上没有工作:
我想改变有图像的背景颜色框。 如何在我的演示网站上实现这一点?
任何建议将非常感激。
谢谢。
它在DOM就绪函数之外,改变这个:
$(function(){ $(".articleBox").click(function(){ window.location=$(this).find("a").attr("href"); return false; }); $('.articleBox').mouseover(function(){ var color = $(this).find("a, .text-h2").css("color"); $(this).find("a, .text-h2").css("color", "rgba(255, 156, 0, 0.8)"); $(this).mouseout(function(){ $(this).find("a, .text-h2").css("color", "rgb(51, 51, 51)"); }); }); }); $(".post-index:has(.wp-post-image)").css("background", "#000");
至
$(function(){ $(".articleBox").click(function(){ window.location=$(this).find("a").attr("href"); return false; }); $('.articleBox').mouseover(function(){ var color = $(this).find("a, .text-h2").css("color"); $(this).find("a, .text-h2").css("color", "rgba(255, 156, 0, 0.8)"); $(this).mouseout(function(){ $(this).find("a, .text-h2").css("color", "rgb(51, 51, 51)"); }); }); $(".post-index:has(.wp-post-image)").css("background", "#000"); });