$(document).bind('dragover', function (e) { var dropZone = $('#dropzone'), timeout = window.dropZoneTimeout; if (!timeout) { dropZone.removeAttr('style').addClass('in'); } else { clearTimeout(timeout); }; if (e.target === dropZone[0]) { dropZone.addClass('hover'); } else { dropZone.removeClass('hover'); }; window.dropZoneTimeout = setTimeout(function () { window.dropZoneTimeout = null; dropZone.removeClass('in hover'); $('.files').checkListLength(); }, 100); });