Javascript 插件上的jQuery错误?

Javascript 插件上的jQuery错误?,javascript,jquery,Javascript,Jquery,在我的网站上,我的浏览器在查看网页时崩溃,它在第21行显示了我的脚本,但我不确定出了什么问题?有人能看到问题吗 jQuery.fn.carousel = function(previous, next, options){ var sliderList = jQuery(this).children()[0]; if (sliderList) { var increment = jQuery(sliderList).children().outerWidth("

在我的网站上,我的浏览器在查看网页时崩溃,它在第21行显示了我的脚本,但我不确定出了什么问题?有人能看到问题吗

jQuery.fn.carousel = function(previous, next, options){
    var sliderList = jQuery(this).children()[0];

    if (sliderList) {
        var increment = jQuery(sliderList).children().outerWidth("true"),
        elmnts = jQuery(sliderList).children(),
        numElmts = elmnts.length,
        sizeFirstElmnt = increment,
        shownInViewport = Math.round(jQuery(this).width() / sizeFirstElmnt),
        firstElementOnViewPort = 1,
        isAnimating = false;

        for (i = 0; i < shownInViewport; i++) {
            jQuery(sliderList).css('width',(numElmts+shownInViewport)*increment + increment + "px");
            jQuery(sliderList).append(jQuery(elmnts[i]).clone());
        }

        jQuery(previous).click(function(event){
            if (!isAnimating) {
                if (firstElementOnViewPort == 1) {
                    jQuery(sliderList).css('left', "-" + numElmts * sizeFirstElmnt + "px");
                    firstElementOnViewPort = numElmts;
                }
                else {
                    firstElementOnViewPort--;
                }

                jQuery(sliderList).animate({
                    left: "+=" + increment,
                    y: 0,
                    queue: true
                }, "swing", function(){isAnimating = false;});
                isAnimating = true;
            }

        });

        jQuery(next).click(function(event){
            if (!isAnimating) {
                if (firstElementOnViewPort > numElmts) {
                    firstElementOnViewPort = 2;
                    jQuery(sliderList).css('left', "0px");
                }
                else {
                    firstElementOnViewPort++;
                }
                jQuery(sliderList).animate({
                    left: "-=" + increment,
                    y: 0,
                    queue: true
                }, "swing", function(){isAnimating = false;});
                isAnimating = true;
            }
        });
    }
};
我用…调用我的插件

$('.viewer').each(function() {
    $(this).carousel('.viewer .simplePrevious', '.viewer .simpleNext');
});

它是在HTML5元素上还是在IE中?
我也有类似的问题,即使是HTML5。必须恢复到xhtml才能再次工作。

你能发布你的html以及如何调用插件吗?你能告诉我们哪一行是第21行吗?我假设这不是文件开始的方式我修改了我的问题@moopetIm没有收到错误@Andy,我的浏览器崩溃,直到我强制退出itok听起来像是一个无限循环。那么它在没有第21行的情况下工作?
showinViewport
有什么值?
$('.viewer').each(function() {
    $(this).carousel('.viewer .simplePrevious', '.viewer .simpleNext');
});