Javascript :has()jquery工作不正常
我正在尝试在我的网站上执行以下操作:Javascript :has()jquery工作不正常,javascript,jquery,Javascript,Jquery,我正在尝试在我的网站上执行以下操作: $(".post-index:has(.wp-post-image)").css("background", "#000"); Js fiddle示例运行良好: 但这在我的演示网站上不起作用: 我想更改有图像的背景色框。如何在我的演示站点上实现这一点 任何建议都将不胜感激 谢谢。它在DOM就绪函数之外,请更改此选项: $(function(){ $(".articleBox").click(function(){ wind
$(".post-index:has(.wp-post-image)").css("background", "#000");
Js fiddle示例运行良好:
但这在我的演示网站上不起作用:
我想更改有图像的背景色框。如何在我的演示站点上实现这一点
任何建议都将不胜感激
谢谢。它在DOM就绪函数之外,请更改此选项:
$(function(){
$(".articleBox").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
<!-- div mouseover change h2 color -->
$('.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)");
});
});
});
<!-- non image div change background color -->
$(".post-index:has(.wp-post-image)").css("background", "#000");
$(函数(){
$(“.articleBox”)。单击(函数(){
window.location=$(this.find(“a”).attr(“href”);
返回false;
});
$('.articleBox').mouseover(函数(){
var color=$(this).find(“a,.text-h2”).css(“color”);
$(this.find(“a,.text-h2”).css(“color”,“rgba(255156,0,0.8)”);
$(this).mouseout(函数(){
$(this.find(“a,.text-h2”).css(“color”,“rgb(51,51,51)”);
});
});
});
$(“.post index:has(.wp post image)”).css(“背景”,“#000”);
到
$(函数(){
$(“.articleBox”)。单击(函数(){
window.location=$(this.find(“a”).attr(“href”);
返回false;
});
$('.articleBox').mouseover(函数(){
var color=$(this).find(“a,.text-h2”).css(“color”);
$(this.find(“a,.text-h2”).css(“color”,“rgba(255156,0,0.8)”);
$(this).mouseout(函数(){
$(this.find(“a,.text-h2”).css(“color”,“rgb(51,51,51)”);
});
});
$(“.post index:has(.wp post image)”).css(“背景”,“#000”);
});
它在DOM就绪函数之外,请更改此选项:
$(function(){
$(".articleBox").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
<!-- div mouseover change h2 color -->
$('.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)");
});
});
});
<!-- non image div change background color -->
$(".post-index:has(.wp-post-image)").css("background", "#000");
$(函数(){
$(“.articleBox”)。单击(函数(){
window.location=$(this.find(“a”).attr(“href”);
返回false;
});
$('.articleBox').mouseover(函数(){
var color=$(this).find(“a,.text-h2”).css(“color”);
$(this.find(“a,.text-h2”).css(“color”,“rgba(255156,0,0.8)”);
$(this).mouseout(函数(){
$(this.find(“a,.text-h2”).css(“color”,“rgb(51,51,51)”);
});
});
});
$(“.post index:has(.wp post image)”).css(“背景”,“#000”);
到
$(函数(){
$(“.articleBox”)。单击(函数(){
window.location=$(this.find(“a”).attr(“href”);
返回false;
});
$('.articleBox').mouseover(函数(){
var color=$(this).find(“a,.text-h2”).css(“color”);
$(this.find(“a,.text-h2”).css(“color”,“rgba(255156,0,0.8)”);
$(this).mouseout(函数(){
$(this.find(“a,.text-h2”).css(“color”,“rgb(51,51,51)”);
});
});
$(“.post index:has(.wp post image)”).css(“背景”,“#000”);
});
需要注意的事情:。出于性能目的,您可能更适合使用需要注意的内容:。出于性能目的,它可能更适合您使用。非常感谢!它工作得很好。非常感谢。@MasatoBrianMiura-没问题,记得接受答案。非常感谢!它工作得很好。非常感谢。@MasatoBrianMiura-没问题,记得接受答案。