jq toggle1.9版本后不支持解决方案
Posted 嘎子哥
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jq toggle1.9版本后不支持解决方案相关的知识,希望对你有一定的参考价值。
<script type="text/javascript"> $(document).ready(function(){ $("button").toggle(function(){ $("body").css("background-color", "green"); }, function(){ $("body").css("background-color", "red"); }, function(){ $("body").css("background-color", "yellow"); }); }); $.fn.toggle = function( fn ) { // Save reference to arguments for access in closure var args = arguments, guid = fn.guid || jQuery.guid++, i = 0, toggler = function( event ) { // Figure out which function to execute var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); // Make sure that clicks stop event.preventDefault(); // and execute the function return args[ lastToggle ].apply( this, arguments ) || false; }; // link all the functions, so any of them can unbind this click handler toggler.guid = guid; while ( i < args.length ) { args[ i++ ].guid = guid; } return this.click( toggler ); } </script>
以上是关于jq toggle1.9版本后不支持解决方案的主要内容,如果未能解决你的问题,请参考以下文章