我有一个带有UpdatePanel的asp.net页面,并且希望通过Ajax调用使滚动事件hander持久。我得到它为输入元素更改事件(见最后一个例子)工作,但我很难与div元素的sroll事件。JQuery On()不适用于div
$(document).ready(function()
{
/* working event fires but not after ajax call */
$("#ctl00_cirsContent_divReportLeft").on("scroll", function() {
alert("test scroll left");
});
/* this one does not work at all */
$(document).on("scroll", "#ctl00_cirsContent_divReportRight", function() {
alert("Test scroll");
});
/* this one works both before and after ajax call */
$(document).on("change", "#ctl00_cirsContent_CtlCalendar1_txtDate", function() {
alert("Test type");
});
});
我错过了什么?
感谢
请注意:*只是想法* - >如果您使用的是C#用户控件,并且此输入的'id' =>'ctl00_cirsContent_divReportLeft'是动态生成的,我建议您使用'class'属性。这应该工作。好的细节在这里:https://api.jquery.com/on/ –