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 //有一个多维数组 $a...

PHP实现根据银行卡号判断银行

bankList.php请在文章末尾下载 header('Content-type:text/html;charset=utf-8'); require_once('bankLis...

php中数组首字符过滤功能代码

复制代码 代码如下: <?php $array = array( 'abcd', 'abcde', 'bcde', 'cdef', 'defg', 'defgh' ); $str...

PHP借助phpmailer发送邮件

本地没有发邮件的服务器,借助现成的SMTP服务器发送邮件是个不错的选择,这里使用到的工具是phpmailer ( Version 5.2.0),SMTP服务器就选gmail和163。 1...

PHP实现二维数组根据key进行排序的方法

本文实例讲述了PHP实现二维数组根据key进行排序的方法。分享给大家供大家参考,具体如下: 在PHP中内置了很多对数组进行处理的函数,有很多时候我们直接使用其内置函数就能达到我们的需求,...