I have 4 DIV
that I want to have a scroll
event fired when you scroll on one of those div's. This is the code below.
$('#div1, #div2, #div3, #div4').scroll(function() {
alert('...');
});
In Firefox/Chrome, this runs fast; however, in Internet Explorer this runs so slow that it actually prevents me from scrolling the div.
I'm using the latest version of JQuery (v.1.4.1).
Question: Is there a more effect way to run the code above? If so, how?
UPDATE: Since it was asked, I've included below my entire code:
$('#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");
if (activeHomeMarkerID) {
// unset the old active house marker to a normal icon
map.markers[activeHomeMarkerID].setIcon('http://example.com/images/house-icon.png');
}
activeHomeMarkerID = activeHomeID.substring(4); // set the new active marker id
map.markers[activeHomeMarkerID].setIcon('http://example.com/images/house-icon-active.png');
});
UPDATE 2:
So I've implemented the timer option below and in IE, it's still just as slow. Any other ideas?