欢迎光临
我们一直在努力

function $(id)js与jquery发生冲突的解决方法

按装以下方法操作:
把以下代码放到起冲突的代码下面

  1. function $(id) { 
  2.      if (typeof jQuery == 'undefined' || (typeof id == 'string' && document.getElementById(id))) { 
  3.           return document.getElementById(id); 
  4.      } else if (typeof id == 'object' || !/^w*$/.exec(id) || 
  5.           /^(body|div|span|a|input|textarea|button|img|ul|li|ol|table|tr|th|td)$/.exec(id)){ 
  6.         return jQuery(id); 
  7.      } 
  8.      return null

比如这样:

  1. <scripttypescripttype="text/javascript" src="js/ssxl.js">script> 
  2. <scripttypescripttype="text/javascript" src="js/jquery-1.2.6.min.js">script><scripttypescripttype="text/javascript" src="js/gd.js">script> 
  3. <script>function $(id) { 
  4. if (typeof jQuery == 'undefined' || (typeof id == 'string' && document.getElementById(id))) { 
  5. return document.getElementById(id); 
  6. } else if (typeof id == 'object' || !/^w*$/.exec(id) || 
  7. /^(body|div|span|a|input|textarea|button|img|ul|li|ol|table|tr|th|td)$/.exec(id)){ 
  8. return jQuery(id); 
  9. return null; 
  10. script> 

 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:英协网 » function $(id)js与jquery发生冲突的解决方法

分享到: 生成海报
avatar

热门文章

  • 评论 抢沙发

    • QQ号
    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    登录

    忘记密码 ?

    切换登录

    注册

    我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活