我有4 DIV,scroll当你滚动其中一个div时我想要一个事件被触发.这是下面的代码.
$('#div1, #div2, #div3, #div4').scroll(function() {
alert('...');
});
Run Code Online (Sandbox Code Playgroud)
在Firefox/Chrome中,运行速度很快; 但是,在Internet Explorer中,它运行速度很慢,实际上阻止了我滚动div.
我正在使用最新版本的JQuery(v.1.4.1).
更新:自从被问及,我已经在我的整个代码下面包含:
$('#div1, #div2, #div3, #div4').scroll(function() {
/* find the closest (hlisting) home listing to the middle of the scrollwindow */
var scrollElemPos = activeHomeDiv.offset();
var newHighlightDiv = $(document.elementFromPoint(
scrollElemPos.left + activeHomeDiv.width() / 2,
scrollElemPos.top + activeHomeDiv.height() / 2)
).closest('.hlisting');
if(newHighlightDiv.is(".HighlightRow")) return;
$('.HighlightRow').removeClass("HighlightRow");
newHighlightDiv.addClass('HighlightRow');
/* change the map marker icon to denote the currently focused on home */
var activeHomeID = newHighlightDiv.attr("id"); …Run Code Online (Sandbox Code Playgroud)