var isDown = false; $(document).ready (function () { $("#mydiv").on("mousedown", function() { isDown = true; alert(isDown); } ); });