为什么要滑动切换跳跃?以及如何让它仅适用于点击的文章?

发布于 2024-12-28 20:10:03 字数 664 浏览 5 评论 0原文

好吧,这是我的 jsfiddle - http://jsfiddle.net/8947F/

基本上,slideToggle 似乎添加了然后去掉底部的一些高度,这样它看起来就像跳跃一样...

而且点击会影响所有隐藏的 div,我如何让它只适用于特别

是这里是我的 jquery

$(function() {
$('article .folder-hover').hide();

    $('article').hover(function(){
    $(this).children('.folder-hover').show();
    },
function(){
    $(this).children('.folder-hover').hide();
});    

});

$(function() {
$('article .folder-items').hide();    


$("article").click(function () {
  $(".folder-items").slideToggle("slow");
});
});

任何获取它的方法仅当开始单击其父级时才影响子级 div? 那“跳跃”是怎么回事???

提前致谢

Ok so here is my jsfiddle - http://jsfiddle.net/8947F/

basically the slideToggle seems to add then take away some height at the bottom so that it looks like it jumps...

Also the clicking affects all of the hidden divs, how do I get it to only apply to the one in particular

here's my jquery

$(function() {
$('article .folder-hover').hide();

    $('article').hover(function(){
    $(this).children('.folder-hover').show();
    },
function(){
    $(this).children('.folder-hover').hide();
});    

});

$(function() {
$('article .folder-items').hide();    


$("article").click(function () {
  $(".folder-items").slideToggle("slow");
});
});

any way to get it so it only affects the child div when it's parent is begin clicked?
and what is up with that 'jump'???

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痴梦一场 2025-01-04 20:10:03

看看这个 jsfiddle

http://jsfiddle.net/8947F/14/

工作顺利!

check out this jsfiddle

http://jsfiddle.net/8947F/14/

works nice n smooth!

饮惑 2025-01-04 20:10:03

因为它正在选择所有文件夹项目。您应该通过传递上下文(在您的情况下为 this )将其限制为在当前文章中查找。试试这个。

$(function() {
    $('article .folder-hover').hide();
    $('article').hover(function(){
        $(this).children('.folder-hover').show();
    },
    function(){
        $(this).children('.folder-hover').hide();
    });    
});

$(function() {
    $('article .folder-items').hide();    

    $("article").click(function () {
      $(".folder-items", this).slideToggle("slow");
    });
});

从folder-items css类中删除高度100%,这将解决跳跃问题

.folder-items {
    clear: left;
    padding-top: 12px;
    margin-left: 48px;
    list-style: none;
}

演示

Because it is selecting all the folder-items. You should restrict it to find with in the current article being clicked by passing a context(this in your case). Try this.

$(function() {
    $('article .folder-hover').hide();
    $('article').hover(function(){
        $(this).children('.folder-hover').show();
    },
    function(){
        $(this).children('.folder-hover').hide();
    });    
});

$(function() {
    $('article .folder-items').hide();    

    $("article").click(function () {
      $(".folder-items", this).slideToggle("slow");
    });
});

Remove height 100% from folder-items css class this will fix the jumping issue

.folder-items {
    clear: left;
    padding-top: 12px;
    margin-left: 48px;
    list-style: none;
}

Demo

誰ツ都不明白 2025-01-04 20:10:03

尝试更改

.folder-items {
    height:auto;
}

http://jsfiddle.net/8947F/4/

Try changing

.folder-items {
    height:auto;
}

http://jsfiddle.net/8947F/4/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文