关于#jQuery#的问题,如何解决?

问题遇到的现象和发生背景

页面有两个div 当鼠标移动到上面那个div时 触发下面div的jQuery的slideToggle方法,但当鼠标离开上面那个div时,下面div将收缩回来。我想要的效果是,当下面那个div展开后 我鼠标移到下面div时,下面这个div不会收缩回去。

问题相关代码,请勿粘贴截图

img

img

你需要把a和b放到一个大盒子里,然后将hover事件添加倒这个大盒子中

纯css可实现

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      position: relative;
      width: 200px;
      height: 40px;
      line-height: 40px;
      background-color: lightblue;
    }
    .box .content {
      width: 100%;
      height: 0;
      position: absolute;
      top: 40px;
      background-color: lightsalmon;
      overflow: hidden;
      transition: all .4s;
    }
    .box:hover .content {
      height: 100px;
    }
  </style>
</head>
<body>
  <div class="box">
    box
    <div class="content">content</div>
  </div>
</body>
</html>