我想用toggle来切换多个单击事件,但是js控制台提示错误如下:

 

Uncaught TypeError: Property 'function (){
alert("func2");
}' of object #<Object> is not a function


我的html源代码如下:

 

 

<html>
<head>
<title>jsDev</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</style>
<script type="text/javascript">
$(function(){
$("button").toggle(function(){
alert("func1");
}, function(){
alert("func2");
}, function(){
alert("func3");
});
})
</script>
</head>
<body>
<button>Click me</button>
</body>
</html>


最后在网上查找了好久,最终在jquery api上得到了雷人的答案。。。

 

jquery toggle问题_ajax


jquery toggle问题_javascript_02


⊙﹏⊙b汗。。得出的结论是,有问题查官网。。官方的最权威