zoukankan      html  css  js  c++  java
  • jquery制作图片瀑布流点击按钮加载更多内容

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

    <script type="text/javascript">

    $(function() {

        //url data function dataType

        function loadMeinv() {

            var data = 0;

            for (var i = 0; i < 25; i++) {//每次加载时模拟随机加载图片

                data = parseInt(Math.random() * 25);

                var html = "";

                html = '<li><div class="water_pic"><a href="#"><img src = img/'

                    + data + '.jpg></a></div><div class="water_user">美女小清新_'

                    + data + '</div><div class="water_option"><a href="" class="option_item">收藏 4</a> <span class="split"></span><a href="" class="option_item option_comt">评论 8</a><span class="split"></span><a href="" class="option_item option_relay">转播 124</a></div></li>';

                $minUl = getMinUl();

                $minUl.append(html);

            }

        }

        loadMeinv();

        //无限加载

        $(window).on("scroll", function() {

            $minUl = getMinUl();

            if ($minUl.height() <= $(window).scrollTop() + $(window).height()) {

                //当最短的ul的高度比窗口滚出去的高度+浏览器高度大时加载新图片

                //loadMeinv();//加载新图片

            }

        })

        function getMinUl() {//每次获取最短的ul,将图片放到其后

            var $arrUl = $("#container .col");

            var $minUl = $arrUl.eq(0);

            $arrUl.each(function(index, elem) {

                if ($(elem).height() < $minUl.height()) {

                    $minUl = $(elem);

                }

            });

            return $minUl;

        }

        //点击更多加载

        $("#loadMeinvMOre").click(function() {

            $minUl = getMinUl();

            loadMeinv();

        });

    })

    </script>

  • 相关阅读:
    docker commit
    镜像原理
    docker command1
    docker镜像命令
    docker work machine
    视图
    后台管理
    模型类
    docker command
    安装virtualenv
  • 原文地址:https://www.cnblogs.com/haiying520/p/5337396.html
Copyright © 2011-2022 走看看