在jQuery中使用循环的选择器问题

问题描述

在我的jQuery代码(见下文)中,我无法更改“ typetravaux”类内容的颜色。
悬停时的不透明度更改是可以的,但是颜色更改不起作用(我尝试了2种不同的方法,但是它们都不起作用)。

你们能告诉我我做错了吗?谢谢!

CSS:

.typetravaux {
  width: 100%;
  color: #ffffff;
}

HTML:

<div class="solutions">
    <div class="bloc1">
      <span class="typetravaux">PLOMBERIE</span>
       <div class="picture"><img src="img/plomberie.png" class="prestapicture"></div>
     </div>
    <div class="bloc2">
      <span class="typetravaux">CHAUFFAGE</span>
       <div class="picture"><img src="img/chauffage.jpg" class="prestapicture"></div>
     </div>
    <div class="bloc3">
      <span class="typetravaux">CLIMATISATION</span>
       <div class="picture"><img src="img/climatisation.jpg" class="prestapicture"></div>
     </div>
</div>

jQuery:

$prestapicture = $('.prestapicture');

for (y=0; y < $prestapicture.length; y++) {
    $prestapicture.eq(y).on("mouseover",function() {
      $(this).css("opacity","0.3");
      $(this).prev(".typetravaux").css("color","black") // **does not work**
    
    })
    
    $prestapicture.eq(y).on("mouseout","1");
      $(".typetravaux").eq(y).css("color","white"); //**does not work either**
    
    })
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)