微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在同一个父母下找到元素

如何解决如何在同一个父母下找到元素

我正试图在select sc.Studentid as [Student ID],StudentName,semester,sum(c.credit) as Creditsemester,cast(sum(w.[Weight]*c.credit) / sum(c.credit) as decimal(5,2)) as [Semester GPA],(select sum(c.credit) from Studentscore) as cumulativecredit from Studentscore sc join Student s on s.Studentid = sc.Studentid join Course c on sc.CourseID = c.CourseID join [weight] w on sc.Grade = w.GRADE group by sc.semester,sc.Studentid,s.StudentName 上悬停以放大.detail中的img。

我尝试使用最接近的兄弟姐妹,但找不到如何选择位于父母兄弟姐妹中的元素。

.imgBox_wrapper

这是我尝试过的

<div class="imgBox">
     <div class="sec03_text">
          <p class="design">Exterior</p>
          <button class="detail">
              <p>text</p>
          </button>
     </div>
     <div class="imgBox_wrapper">
          <img src="image/exterior.png" alt="nth">
     </div>
</div>

解决方法

找到主父上的find

$(document).ready(function(){
  $('.detail').hover(function(){
    //this runs on mouse enter
    $(this).closest('.imgbox').find('.imgbox_wrapper img').css('transform','scale(2,2)');
  },function(){
    //this runs on mouse leave
    $(this).closest('.imgbox').find('.imgbox_wrapper img').css('transform','scale(1,1)');
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="imgbox">
     <div class="sec03_text">
          <p class="design">Exterior</p>
          <button class="detail">
              <p>text</p>
          </button>
     </div>
     <div class="imgbox_wrapper">
          <img src="image/exterior.png" alt="nth">
     </div>
</div>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。