我有一個帶有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/ –