类型错误:container.montage不是函数max:300

TypeError: container.montage is not a function max: 300

本文关键字:函数 max montage 错误 container 类型      更新时间:2023-09-26

我有以下Jquery代码,这是一个错误

$container.montage不是一个函数

我正在关注这个库,我的浏览器没有显示任何其他错误。我已经检查过我正在从FireBug加载所需的库,但仍然无法弄清楚这里出了什么问题。

$(function() {
    var $container = $('#am-container'),
           $imgs = $container.find('img').hide(),
           totalImgs = $imgs.length,
           cnt = 0;
        $imgs.each(function(i) {
            var $img = $(this);
            $('<img/>').load(function() {
                ++cnt;
                if (cnt === totalImgs) {
                    $imgs.show();
                    $container.montage({
                        fillLastRow: true,
                        alternateHeight: true,
                        alternateHeightRange: {
                            min: 75,
                            max: 300
                        }
                    });
                    /* 
                     * just for this demo:
                     */
                    $('#overlay').fadeIn(500);
                }
            }).attr('src', $img.attr('src'));
        });
    });

这是我的HTML

<div class="main-gallary">
   <div class="container">
      <div id="am-container" class="am-container">
          <a href="#">
             <img class="ui-draggable" src="images/gallary/img-1.jpg" style="display: inline; position: relative;">
          </a>
          <a href="#">
          <a href="#">
     </div>
   </div>
</div>

在HTML文档中,在代码的其余部分之前,应该有与下面类似的行。

加载jQuery(您可能已经有了):

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

加载jQuery蒙太奇插件:

<script type="text/javascript" src="js/jquery.montage.min.js"></script>

src="js/jquery.montage.min.js"需要对文件所在的位置进行更正。使用该路径,您可以将其上传到web服务器上名为js的文件夹中。