<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>toggle()方法的动画切换效果</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>toggle()方法的动画切换效果</h3>
<div>
<h4>
<span class="fl">我喜欢吃的水果</span>
<span class="fr" id="spnTip">显示</span>
</h4>
<ul>
<li>苹果</li>
<li>甘桔</li>
<li>梨</li>
</ul>
</div>
<script type="text/javascript">
$(function () {
var $spn = $("#spnTip");
$("h4").bind("click", function () {
$("ul").toggle(function(){
alert(1);
},function(){
alert(2);
})
});
});
</script>
</body>
</html>
//点击h4 每次只会alert(2); 有没高手知道为什么?
pardon110