因此,我有几个文章标签,每个链接都有一个链接,当它需要更改包含该文章内图像的div的背景时。我希望链接悬停只适用于它所在的文章,而不会影响其他文章。下面的代码似乎也是针对其他文章的div。请有人指出我正确的方向?非常感谢当鼠标悬停在链接上时,改变div的颜色
$(".edgtf-pli-link").on("hover", function() {
$(".edgtf-pli-image").css("background", "red");
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<article class="edgtf-pl-item post-36">
<div class="edgtf-pl-item-inner">
<div class="edgtf-pli-image">
<img width="80" height="106" src="garden-featured.jpg" />
</div>
<div class="edgtf-pli-text-holder">
<div class="edgtf-pli-text-wrapper">
<div class="edgtf-pli-text">
<h4 itemprop="name" class="edgtf-pli-title entry-title">Garden</h4>
<p itemprop="description" class="edgtf-pli-excerpt"></p>
</div>
</div>
</div>
<a itemprop="url" class="edgtf-pli-link" href="http://localhost:8888/" target="_self"></a>
</div>
</article>
<article class="edgtf-pl-item post-37">
<div class="edgtf-pl-item-inner">
<div class="edgtf-pli-image">
<img width="80" height="106" src="wall-featured.jpg" />
</div>
<div class="edgtf-pli-text-holder">
<div class="edgtf-pli-text-wrapper">
<div class="edgtf-pli-text">
<h4 itemprop="name" class="edgtf-pli-title entry-title">Wall</h4>
<p itemprop="description" class="edgtf-pli-excerpt"></p>
</div>
</div>
</div>
<a itemprop="url" class="edgtf-pli-link" href="http://localhost:8888" target="_self"></a>
</div>
</article>
尝试'$(this).find('。edgtf-pli-image')。css(“background”,“red”);'而不是 – Toxide82
你介意去除水平滚动条吗?这会提高可读性。 – reporter