唯爱阳 2013-12-24 08:18
浏览 3364

如何解决页面两个js冲突问题

我写了两段js,单独使用能正常显示,到一个页面后有一个就没效果了,希望各位大神可以帮忙解答。。。
这是第一段

$(function(){ $('#banner').cycle({ fx:'scrollLeft', pager:'#btn' }); $('#marquee').marquee({ direction: 'left', scrollDelay:20 }); }) $(function(){ //防止跟已有js变量命名冲突 var jsBottom={}; jsBottom.oSlide=$("#slide"); jsBottom.oTop=jsBottom.oSlide.find("#totop"); jsBottom.ieTop=0; jsBottom.toTopTime=300;//回到顶部所用时间默认为0.3s /* @param--jsBottom.setTop为回到顶部主函数 @param--showHeight滚动条滚动多少距离,显示回到顶部按钮默认为500px */ jsBottom.setTop=function(showHeight){ // 解决fixed属性在ie6下不生效 if($.browser.msie&&$.browser.version=="6.0"){ jsBottom.ieTop=document.documentElement.scrollTop+document.documentElement.clientHeight-parseInt(jsBottom.oSlide.css('height'))-10; jsBottom.oSlide.css("top",jsBottom.ieTop); } //IE浏览器下document.body.scrollTop始终为零,由此判断浏览器 if(document.body.scrollTop==0){ if(document.documentElement.scrollTop<=showHeight){ jsBottom.oTop.css('display','none'); }else{ jsBottom.oTop.css('display','block'); } }else{ //谷歌、火狐浏览器 if(document.body.scrollTop<=showHeight){ jsBottom.oTop.css('display','none'); }else{ jsBottom.oTop.css('display','block'); } } } // 鼠标hover事件切换回到顶部按钮背景,不需要可直接删掉代码 jsBottom.oTop.hover(function(){ $(this).attr('class','totop_a'); },function(){ $(this).attr('class','totop_u'); }); //window滚动事件 $(window).scroll(function(){ //此处设置滚动距离出现回到顶部按钮 jsBottom.setTop(500); }); //回到顶部点击事件 jsBottom.oTop.click(function(){ //谷歌、火狐浏览器 $(document.body).animate({ scrollTop:0 },jsBottom.toTopTime); //ie浏览器 $(document.documentElement).animate({ scrollTop:0 },jsBottom.toTopTime); }); })

第二段

$(function() { $("#scroller_roll1").scroller_roll({ title_show: 'enable',//enable disable time_interval: '15', window_background_color: "none", images_width: '158', images_height: '309', show_count: '4', window_padding: '0', border_size: '1', border_color: '#f3f3f3', }); });
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler