首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

引用jquery库,js代码失效.解决方案

2012-03-08 
引用jquery库,js代码失效.HTML codescript typetext/javascript srccommon/jquery-1.2.6.min.js/

引用jquery库,js代码失效.

HTML code
<script type="text/javascript" src="common/jquery-1.2.6.min.js"></script><script type="text/javascript" src="common/jcarousellite.min.js"></script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><style type="text/css">#scroll213{margin:100px;width:498px;height:143px;background:#F3F3F3;border:#E3E3E3 1px solid;padding:5px;}#prev213{width:15px;height:72px;float:left;text-indent:-5000px;background:url(images/prev.jpg) no-repeat;cursor:pointer;margin-top:10px;}#next213{width:15px;height:72px;float:right;text-indent:-5000px;background:url(images/next.jpg) no-repeat;cursor:pointer;margin-top:10px;}#box213{width:440px;float:left;display:block;overflow:hidden;margin-left:5px;}#box213 ul li{width:110px;float:left;text-align:center;}#box213 ul li a{display:block;color:#666;padding:5px 0;}#box213 ul li a:hover{background:#d1d1d1;color:#000;}#box213 ul li a img{width:100px;height:80px;margin-bottom:5px;}@charset "utf-8";/* CSS Document By Raceman 2009-10-17 17:08*/body,h1,h2,h3,h4,h5,h6,p,ol,ul,li,dl,dt,dd{padding:0;margin:0;}li{list-style:none;}img{border:none;}u{text-decoration:none;}em{font-style:normal;}a{color:#424242;text-decoration:none;outline:none;blr:expression(this.onFocus=this.blur());}body{font-size:12px;font-family: Arial,Verdana, Helvetica, sans-serif; word-break:break-all;}.box{margin:0 auto;text-align:left;width:920px;}.clear{clear:both;}</style><script type="text/javascript">   $(document).ready(function(){    $("#box213").jCarouselLite({        btnPrev: "#prev213",        btnNext: "#next213",           auto: 4000,//图片停留时间           scroll: 4,//每次滚动覆盖的图片个数           speed: 1000, //设置速度,0是不动。其次就是数字越大 ,移动越慢。           vertical: false,//横向(true),竖向(false)           visible: 4, //显示的数量           circular: true //是否循环    });});</script><script type="text/javascript">(function($) {    $.fn.jCarouselLite = function(o) {        o = $.extend({            btnPrev: null, btnNext: null, btnGo: null, mouseWheel: false, auto: null, speed: 200, easing: null, vertical: false, circular: true, visible: 3, start: 0, scroll: 1, beforeStart: null, play: true,            afterEnd: null        }, o || {});        return this.each(function() {            var b = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width";            var c = $(this), ul = $("ul", c), tLi = $("li", ul), tl = tLi.size(), v = o.visible;            ul.bind("mouseover", function() {                if (o.play) {                    o.play = false;                }            })            ul.bind("mouseout", function() {                if (!o.play) {                    o.play = true;                }            })            if (o.circular) {                ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone());                o.start += v            }            var f = $("li", ul), itemLength = f.size(), curr = o.start; c.css("visibility", "visible");            f.css({ overflow: "hidden", float: o.vertical ? "none" : "left" });            ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" });            c.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" });            var g = o.vertical ? height(f) : width(f);            var h = g * itemLength;            var j = g * v; f.css({ width: f.width(), height: f.height() });            ul.css(sizeCss, h + "px").css(animCss, -(curr * g));            c.css(sizeCss, j + "px");            if (o.btnPrev) $(o.btnPrev).click(function() {                return go(curr - o.scroll)            });            if (o.btnNext) $(o.btnNext).click(function() {                return go(curr + o.scroll)            });            if (o.btnGo) $.each(o.btnGo, function(i, a) {                $(a).click(function() { return go(o.circular ? o.visible + i : i) })            });            if (o.mouseWheel && c.mousewheel) c.mousewheel(function(e, d) {                return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll)            });            if (o.auto) {                setInterval(AutoPlay, o.auto + o.speed);            }            function vis() {                return f.slice(curr).slice(0, v)            };            function AutoPlay() { if (o.play) { go(curr + o.scroll); } };            function go(a) {                if (!b) {                    if (o.beforeStart) o.beforeStart.call(this, vis());                    if (o.circular) {                        if (a <= o.start - v - 1) {                            ul.css(animCss, -((itemLength - (v * 2)) * g) + "px");                            curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll                        }                        else if (a >= itemLength - v + 1) {                            ul.css(animCss, -((v) * g) + "px");                            curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll                        }                        else                            curr = a                    }                    else {                        if (a < 0 || a > itemLength - v)                            return;                        else curr = a                    }                    b = true;                    ul.animate(animCss == "left" ? { left: -(curr * g)} : { top: -(curr * g) }, o.speed, o.easing, function() {                        if (o.afterEnd) o.afterEnd.call(this, vis()); b = false                    });                    if (!o.circular) {                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");                        $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > itemLength - v && o.btnNext) || []).addClass("disabled")                    }                } return false            }        })    };    function css(a, b) { return parseInt($.css(a[0], b)) || 0 };    function width(a) { return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight') };    function height(a) { return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom') }})(jQuery);</script> 




引用<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>原本好的代码就失效了,想问问那里不对了.

[解决办法]
把你 代码里的$ 换成个别的符号 jq里对那个有定义!!!冲突啦!
[解决办法]
<script type="text/javascript" src="common/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="common/jcarousellite.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

你引用了两个版本的jquery
[解决办法]
<script type="text/javascript" src="common/jcarousellite.min.js"></script>
这一句放在下面
[解决办法]
<script type="text/javascript" src="common/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="common/jcarousellite.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

咋引入了两个jquery了呀~
去掉一个像这样 不就可以啦~
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
<script type="text/javascript" src="common/jcarousellite.min.js"></script>

热点排行