原创作者:田超凡(程序员田宝宝)
版权所有,引用请注明原作者,严禁复制转载
$.fn.toggle = function( fn, fn2 ) {
var args = arguments,guid = fn.guid || $.guid++,i=0,
toggle = function( event ) {
var lastToggle = ( $._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
$._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
event.preventDefault();
return args[ lastToggle ].apply( this, arguments ) || false;
};
toggle.guid = guid;
while ( i < args.length ) {
args[ i++ ].guid = guid;
}
return this.click( toggle );
};