$.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 );
};
本地调用:
$('#free_tag a').toggle(function(){
$(this).addClass('on')
},jQuery.noop )