---
title: "十九、标准动画"
author: "youyang_java"
date: "2013-05-08T09:20:03Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2013-05-08T09:20:03Z"
id: 1861218
url: "https://youyang-java.iteye.com/blog/1861218"
---

// $(".topicList h3").click(function(){  
    // var uln = $(this).next("ul");  
    // if(uln.css("display")=="none") {  
        // uln.css("display","block");  
    // } else {  
        // uln.css("display","none");  
    // }  
// });

// $(".topicList h3").toggle(function(){  
    // $(this).next("ul").css("display","block");  
// },function(){  
    // $(this).next("ul").css("display","none");  
// });

/\**  
 * 可以使用jquery说提供的show和hide来完成带缓动的隐藏和显示效果  
 * 由于两个方法比较类似，可以直接使用toggle来完成操作  
 \*/  
// $(".topicList h3").toggle(function(){  
    // $(this).next("ul").show(1000);  
// },function(){  
    // $(this).next("ul").hide(1000);  
// });

/\**  
 * toggle如果有两个参数，并且都是函数，表示第一次点击执行第一个函数  
 * 第二次点击执行第二个函数  
 \*/  
$(".topicList h3").toggle(topicHandler,topicHandler);

function topicHandler() {  
    //使用fadeIn,show,slideDown可以完成某个容器的显示  
    //使用fadeOut,hide,slideUp可以完成某个容器的隐藏  
    //所以可以通过各个的toggle来完成两个之间的轮换  
    $(this).next("ul").fadeToggle(1000);  
}