jQuery调整大小事件处理程序不在DIV上工作

时间:2013-04-03 11:52:02

标签: jquery html css resize height

我试图让一个分隔符在另一个分隔符由于内容被加载到其中而调整大小时调整大小。当我将resize事件处理程序绑定到加载内容的分隔符时,当它被加载并且分隔符伸展以适应它时,永远不会调用该事件。这是因为没有通过CSS在分隔符上设置明确的“height”属性吗?

这是一个JSFiddle来演示:http://jsfiddle.net/q2pJ9/1/

HTML:

<div class="container">
    <button>Click me</button>
    <div class="content"></div>
</div>
<div class="other_container">
    <p>Will appear when "container" extends.</p>
</div>

CSS:

.content{
    display:none;
    height: 200px;
    background: grey;
}
.other_container{
    display: none;
}

使用Javascript:

$("button").click(function(){
    $(".content").slideToggle();
});
$(".container").resize(function(){
    $(".other_container").fadeIn();
});

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我不确定我是否真的理解但你会这样吗?

$("button").click(function(){
   $(".content").slideToggle(1500 , function(){
      $(".other_container").fadeIn();
   });
});

链接到示例http://jsfiddle.net/q2pJ9/6/

相关问题