There is a task - to make the block invisible when scrolling.
function closeBox() { $('#block').css('display', 'none'); } $('#block').scroll(function(){ close(); });
So it looks inefficient. When scrolling the page, the handler is constantly called.
You can somehow dynamically attach scroll(function(){})
to the #block
element when displaying ( .css('display', 'block')
) and remove the handler after closing ( .css('display', 'none')
)?