1、怎么判断滚动条到达底部
<style>
*{margin:0;padding:0}
body{
height: 2000px;
}
div{
width:300px;
height: 1700px;
background-color: red;
}
</style>
</head>
<body>
<div>
</div>
<script>
var bodyH = document.body.clientHeight;
var vh = document.documentElement.clientHeight;
// console.log(bodyH)
console.log(vh)
/* 滚动条滚动的距离+vh ==bodyH */
window.onscroll= function(){
var scrollTop = window.scrollY;
console.log(scrollTop)
}
/* scrollTop+vh ==bodyH 判断页面到底了*/
</script>
</body>
</html>
2、点谁删除谁
<ul>
<li>html <button>删除</button></li>
<li>css <button>删除</button></li>
<li>javascript <button>删除</button></li>
</ul>
<script>
var btns = document.getElementsByTagName("button");
/* 1、给每个btn绑定点击事情 */
for(var i=0;i<btns.length;i++){
btns[i].onclick = function(){
/* 2、点击对应的元素,将其父元素删除 */
var isShow = confirm("是否删除");
console.log(isShow);
if(isShow){
this.parentNode.style.display="none"
}
}
}
</script>