如何向jQuery slidetoggle添加不透明度褪色效果? [英] how to add an opacity fading effect to to the jquery slidetoggle?

查看:82
本文介绍了如何向jQuery slidetoggle添加不透明度褪色效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码在div上上下滑动:

I'm using the following code to slide up and down a div:

$(document).ready(function(){
    $(".toggle-button").click(function () {
        $(".about").slideToggle("slow");
    });
});

我想为切换按钮添加淡入和淡出效果. 有关如何执行此操作的任何建议?

I will like to add a fade in and fade out effect to the toggle button. Any suggestions about how to do that?

推荐答案

一种简单的方法是将toggle值传递给动画():

A simple way to achieve this is to pass the toggle value to animate():

$(document).ready(function() {
    $(".toggle-button").click(function() {
        $(".about").animate({
            height: "toggle",
            opacity: "toggle"
        }, "slow");
    });
});

您可以在此小提琴中看到结果.

这篇关于如何向jQuery slidetoggle添加不透明度褪色效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆