湖中沉 发表于 2011-10-25 14:04:33

discuz如何解决jquery冲突的问题

为什么冲突呢?因为jquery用的是$符号选择页面元素,discuz呢内置$,所有就冲突了,但jquery有解决方案,不知道的去官方看看文档吧。举个例子吧,滑动切换,代码


<script language="JavaScript" type="text/javascript" src="static/js/jquery-1.6.4.min.js"></script>
<script>
   var jq = jQuery.noConflict();
   jq(function(){
    jq('.t1').hover(function(){
         jq('.cont1').show();
         jq(this).css('color','#ccc');
         jq(this).css('cursor','pointer');
         jq('.cont2').hide();
      },function(){
         jq(this).css('color','#000');
      });
      jq('.t2').hover(function(){
         jq('.cont2').show();
         jq(this).css('color','#ccc');
         jq(this).css('cursor','pointer');
         jq('.cont1').hide();
      },function(){
         jq(this).css('color','#000');
      });
});
</script>
<!--{subtemplate common/footer}-->看代码,应该知道代码在什么位置吧。重点是:var jq = jQuery.noConflict();
页: [1]
查看完整版本: discuz如何解决jquery冲突的问题