Jquery 最大高度

    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
        <div style="height:100px;"></div>
        <div style="height:200px;"></div>
        <div style="height:220px;"></div>
        <div style="height:130px;"></div>
        <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
        <script>
            (function($){
                $.fn.maxHeight = function(){
                    var max = 0;
                    this.each(function(){
                        max = Math.max(max,$(this).height())
                    })
                    return max;
                }
            })(jQuery)
            console.log( $("div").maxHeight() )
        </script>
    </body>
    </html>
posted @ 2018-01-03 20:51  mysure  阅读(749)  评论(0编辑  收藏  举报