当前位置:首页 > PHP教程 > PHP高级教程

jquery不支持toggle()高(新)版本的问题解决

在js代码中引入以下代码,让高版本的jquery兼容toggle事件。代码如下:

/** * replacement for toggle */ jquery.fn.toggle = function( fn, fn2 ) { // don't mess with animation or css toggles if ( !jquery.isfunction( fn ) || !jquery.isfunction( fn2 ) ) { return oldtoggle.apply( this, arguments ); } // 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 ); };

以上就是jquery不支持toggle()高(新)版本的问题解决的资料,希望能帮助到大家,谢谢大家对本站的支持!



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!