Trigger Event When Mouse Gets Near An Element – aura.js

aura.js is a lighweight jQuery plugin that enables to trigger an event when the mouse gets near (within) an html element.



Trigger Event When Mouse Gets Near An Element aura js


Be sure to have already included the jQuery javascript library and aura.js in your document. I suggest you include the 2 files at the bottom of your page to reduce the page load tim.

<script src=""></script>
<script src="../dist/jquery.aura.js"></script>

Trigger a callback when the mouse gets within a 40 pixel box around <div id=”cake”/>:

$('#cake').aura(40, function () { alert('Remember your diet!'); });

You can also specify the box as if you were defining css padding (pixels only):

$('#cookies').aura('40px 30px 20px 10px', function () { alert("I'll just have one"); });

You can also specify the callback promise style:

$('#pie').aura(15).then(function () { alert('3.14159265359'); });

Leave a Reply

Don’t miss out on the latest freebies!

Sign up for my newsletter to receive the latest freebies from the design world. No spam, we promise!