我正在使用jQuery的slidetoggle,我想知道是否有一种方法可以让它从底部向上滑动,我看到的任何地方似乎无法找到答案,这是我正在使用的代码:
jQuery(document).ready(function(){
jQuery(".product-pic").hover(function(){
jQuery(this).find('.grid-add-cart').slidetoggle('2000',"eaSEOutBack",function() {
// Animation complete.
});
});
});
解决方法
你想实现像
this这样的东西吗?
HTML
<div id="Box">
<div id="panel">
</div>
</div>
CSS
#Box
{
height: 100px;
width:200px;
position:relative;
border: 1px solid #000;
}
#panel
{
position:absolute;
bottom:0px;
width:200px;
height:20px;
border: 1px solid red;
display:none;
}
JS
$("#Box").hover(function(){
$("#panel").slidetoggle();
},function(){
$("#panel").slidetoggle();
});
或根据Roko建议的更新
var panelH = $('#panel').innerHeight();
$("#Box").hover(function(){
$("#panel").stop(1).show().height(0).animate({height: panelH},500);
},function(){
$("#panel").stop(1).animate({height: 0},500,function(){
$(this).hide();
});
});