jquery - 如何使用 slidedown 和 slide up jquery

标签 jquery css

我想在鼠标悬停时在下拉菜单中显示一个汽车信息类...相反,当鼠标移开时让它向上滑动。 我如何在 jquery 中执行此操作?

 $(".items .title-bar").on("mouseover",this, function () {
        //how use car-info slide down
  });
  $(".items .title-bar").on("mouseout",this, function () {
        //i wanted  .title-bar and .car-info .. mouseout event and .car-info is slideup

});

mouseover 之前

enter image description here

使用鼠标悬停

enter image description here

//看我的jfiddle http://jsfiddle.net/kisspa/es3gx/

最佳答案

首先你应该包括 jQuery 库,然后有几个错误(JS 和 CSS)。

看这里:

$(".items .title-bar").on("mouseover", function () {
        $(this).closest(".items").find(".car-info").slideDown(); //@Vedant Terkar edit
});
$(".items .title-bar").on("mouseout", function () {
        $(this).closest(".items").find(".car-info").slideUp();   //@Vedant Terkar edit
});

并且在 CSS 中,您应该删除 z-index,并使用 display 属性隐藏框:

.car-info{
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 15px 10px;
    text-align: justify;
    display: none;    
}

fiddle 演示在这里:http://jsfiddle.net/es3gx/5/

关于jquery - 如何使用 slidedown 和 slide up jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24506307/

相关文章:

jquery - Rails jquery 适用于本地主机,但不适用于 heroku

javascript - 重置幻灯片以使用每个点击处理按钮从第一张幻灯片开始

jquery - SVG 动画在 IE9 中不起作用

jquery - 我怎样才能使第一个 ul 中的 li 超过第二个 ul?

javascript - 将列的鼠标悬停区域限制为其自身形状与周围区域

html - 我们可以在 CSS 中使用嵌套的子选择器还是 ">"

css - 菜单 'border-right: none' 不工作

javascript - JQuery Onclick Change Image Src 不刷新图像

javascript - 在页面加载时持续检查 Oracle 记录

jquery - 通过“上一个”和“下一个”按钮在 DIV 之间旋转