<!DOCTYPE html>
<html>
<head>
<title>当滚动条滑到底部时自动加载内容</title>
<meta http-equiv=
"Content-Type"
content=
"text/html;charset=UTF-8"
/>
<style type=
"text/css"
>
body{
background-color:
#808080;
}
#main{
margin:0 auto;
width: 960px;
}
#content{
position: absolute;
width: 960px;
}
#img{
margin: 0;
padding: 0;
}
#img li{
list-style-type: none;
background-color: salmon;
margin: 0;
margin-top:10px;
border-bottom: solid 1px hotpink;
text-align: center;
}
</style>
</head>
<body>
<div id=
"main"
>
<div id=
"content"
>
<ul id=
"img"
>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
<li>13</li>
<li>14</li>
<li>15</li>
<li>16</li>
<li>17</li>
<li>18</li>
<li>19</li>
<li>20</li>
<li>21</li>
<li>22</li>
<li>23</li>
<li>24</li>
<li>25</li>
<li>26</li>
<li>27</li>
<li>28</li>
<li>29</li>
<li>30</li>
</ul>
</div>
</div>
<script type=
"text/javascript"
src=
"js/jquery-1.7.2.min.js"
></script>
<script type=
"text/javascript"
>
var
content=document.getElementById(
"img"
).innerHTML;
function
addLi(){
document.getElementById(
"img"
).innerHTML+=content;
}
$(window).scroll(
function
(){
var
htmlHeight=document.body.scrollHeight||document.documentElement.scrollHeight;
var
clientHeight=document.body.clientHeight||document.documentElement.clientHeight;
var
scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
if
(scrollTop+clientHeight==htmlHeight){
addLi();
}
})
</script>
</body>
</html>