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

yipeiwu_com5年前PHP代码库

在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()高(新)版本的问题解决的资料,希望能帮助到大家,谢谢大家对本站的支持!

相关文章

我的php学习笔记(毕业设计)

php语法简单,应用也非常好,而且类库强大,确实能写出很强大的服务器端。对于我这种只需要小功能服务器的人来说,再好不过了。   单纯的说学习php,我觉得还是看手册的好。花了几天时间看了...

PHP实现的大文件切割与合并功能示例

本文实例讲述了PHP实现的大文件切割与合并功能。分享给大家供大家参考,具体如下: 分割代码 split.php <?php $i = 0;...

PHP设计模式之结构模式的深入解析

结构模式之间有许多相似之处,因为在对象模型结构中存在几种关系:类之间的继承和实现,加上对象组合,这些是PHP设计模式的主要目的。 对象组合的最大优势在于可以在运行时基于配置建立起一个关系...

php查找字符串出现次数的方法

本文实例讲述了php查找字符串出现次数的方法。分享给大家供大家参考。具体方法如下: 在php中查找字符串出现次数的查找可以通过substr_count()函数来实现,下面就来给大家详细介...

PHP实现webshell扫描文件木马的方法

本文实例讲述了PHP实现webshell扫描文件木马的方法。分享给大家供大家参考,具体如下: 可扫描 weevelyshell 生成 或加密的shell 及各种变异webshell 目前...