santa santa - 2 years ago 153
jQuery Question

Animate only once

I use jQuery .animate() to move an item once, but it seems to be moving in increments of 100px multiple times. Is it because of mouseover over?

var ww = $(window).width();

$(document).on('mouseover', '#myTarget', function () {
var dp = $(this).offset().left;

if ((ww - dp) < 150) {

Answer Source

Changing it to $(document).on('mouseenter', '#myTarget', function () { would be better. Every time your mouse enters or leaves the element or one of its children, a mouseover event is triggered. This will not happen with mouseenter. The example here shows this.

See this answer for a similar question and the source for the example provided.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download