当鼠标悬停在另一个div

时间:2015-10-26 21:24:29

标签: jquery

嘿伙计们,我不确定为什么这不起作用......好像应该这样,谢谢你的帮助。



$(document).ready(function() {
  $('.newProductLearnMore').hover(function() {
    $('.newProductDesc').css('borderTop', '5px solid #006699');
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="newProductWrapper" style="margin-top: -100px;">
  <div class="newProductImage">
    <img src="" alt="" height="300" width="550">
  </div>
  <div class="newProductDesc"> <span class="name">test</span>
    <br /> <span class="desc">test</span>

  </div>
  <a href=#>
    <div class="newProductLearnMore"><span>LEARN MORE!</span>
    </div>
  </a>

</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

使用mouseenter和mouseleave事件处理程序

$(document).ready(function() {
    $('.newProductLearnMore').mouseenter(function() {
        $('.newProductDesc').css('borderTop', '5px solid #006699');
    });

    $('.newProductLearnMore').mouseleave(function() {
        //return to initial border color
    });
});