我有一个由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
没有触发。我改变了 body
元素的 scroll
属性、body
和 form
元素的溢出属性,尝试将 scroll
事件绑定到不同的对象(window
、body
、form
),但是当将 scroll
事件更改为 click
事件时,它就会触发。除了滚动元素的 overflow
属性外,我没有找到任何原因。