<input data-id="6" value="删除">
然后通过xx.getAttribute("data-id")来获取。如果你用jQuery的话直接$(this).attr("data-id")来获取。
这里的data-id是你自己随意定义的,只要不和其他的属性名冲突就好。有些人习惯写item-id随便你的喜好了。
js监视滚动事件的函数是onscroll
js语法:element.onscroll = functionReference
html语法:<element onscroll="myScript">
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8" />
<style>
#container {
position: absolute
height: auto
top: 0
bottom: 0
width: auto
left: 0
right: 0
overflow: auto
}
#foo {
height:1000px
width:1000px
background-color: #777
display: block
}
</style>
</head>
<body>
<div id="container">
<div id="foo"></div>
</div>
<script type="text/javascript">
// js绑定你需要监控滚动事件的dom,也可以绑定document.body监控整个网页滚动
// 也可以监控具体的dom滚动,像下面的container Id对象
document.getElementById('container').onscroll = function() {
console.log("scrolling")
}
</script>
</body>
</html>