为了账号安全,请及时绑定邮箱和手机立即绑定

​Uncaught TypeError: $(...).on is not a function 浏览器显示$(window).on("load",function(){ })不是函数是什么意思

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>瀑布流布局</title>

<style>

body{margin: 0;padding: 0;}

img{border: none;vertical-align: top;}

#main{position:relative;}

.box{float: left;padding: 15px 0 0 15px;}

.pic{padding: 10px;border: 1px solid #ccc;border-radius: 5px;box-shadow: 0 0 5px #ccc;}

.pic img{width: 165px;height: auto;}

</style>

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

<script>

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

waterfall();

})

function waterfall(){

var $box=$("#main>div");

var boxW=$box.eq(0).outerWidth();

var cols=Math.floor($(window).width()/boxW);

$('#main').width(boxW*cols).css('margin','0 auto')

var arrH=[];

$box.each(function(index,value){

var h=$box.eq(index).outerHeight();

if(index<cols){arrH[index]=h;}

else{

var hMin=Math.min.apply(null,arrH);

var minIndex=$.inArray(hMin,arrH);

$(value).css({

'position':'absolute',

'top':hMin+'px',

'left':boxW*minIndex+'px'

})

arrH[minIndex]+=$box.eq(index).outerHeight();;

}

})

}

</script>

</head>

<body>

<div id="main">

<div class="box">

<div class="pic">

<img src="img/0.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/1.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/2.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/3.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/4.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/5.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/6.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/7.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/8.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/9.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/9.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/9.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/10.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/11.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/12.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/13.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/14.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/15.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/16.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/17.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/18.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/19.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/20.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/21.jpg"/>

</div>

</div>

<div class="box">

<div class="pic">

<img src="img/22.jpg"/>

</div>

</div>

<br clear="all">

</div>

</body>

</html>


正在回答

1 回答

题主,你没有引用jQuery库啊!

0 回复 有任何疑惑可以回复我~
#1

murphy3292525 提问者

呃呃,我被自己蠢哭了== 多谢!
2016-08-16 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

​Uncaught TypeError: $(...).on is not a function 浏览器显示$(window).on("load",function(){ })不是函数是什么意思

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信