我的 SharePoint 页面生成了这个 HTML(已剪辑):
<body scroll="yes" onload="if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();" class="v4master" style="overflow: scroll" spellcheck="false">
<form name="aspnetForm" method="post" action="/Lists/List/EditNewForm.aspx?ID=2&Source=https%3A%2F%2Fsp2010-test%2Eatwss%2Ecom%2FLists%2FList%2FAllItems%2Easpx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" style="overflow: scroll">
// some html here
<div id="competenceTotalSum" style="position: absolute; left: 500px; top: 400px; width: 100px; height: 50px; background-color:gray" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("form#aspnetForm").bind("scroll", function(e){
alert("scroll");
$("#competenceTotalSum").css("top", $(this).scrollTop() + 400);
});
});
</script>
// some html here
</form>
</body>
事件scroll
未触发。我更改了andscroll
的属性body
、溢出属性,尝试将事件绑定到不同的对象(、、、)。当将事件更改为事件时 - 它会触发。除了滚动元素的属性外,我没有找到任何原因。body
form
scroll
window
body
form
scroll
click
overflow