Mark Richards
Mark Richards

Reputation: 434

mouseover and mouseleave ON / OFF Not Working

here is my code in fiddle http://jsfiddle.net/4yb42/10/

the problem is after off mouseoveror mouseleave by this code:

jQuery('.star-rating span').off('mouseover mouseleave');

how to ON or start again effect of mouseoveror mouseleave ??

it is not working after you click fist time on ClickMe1 ClickMe2 ClickMe3 ClickMe4 ClickMe4 (the convert in to red color) then click on reset button , and now mouse over on ClickMe1 ClickMe2 ClickMe3 ClickMe4 ClickMe4 its on effect on mouse over

Upvotes: 0

Views: 162

Answers (2)

Bhavik
Bhavik

Reputation: 4904

Working Fiddle

  1. Defining function's for each event,
  2. unbinding them using of() and
  3. again binding those functions using on().

Code

jQuery('.star-rating span').on({
    mouseenter: function () {
        me(this);
    },
    mouseleave: function () {
        ml(this);
    },
    click: function () {
        cl(this);
    }
});

Hope it helps..!!

Upvotes: 2

Maurice Perry
Maurice Perry

Reputation: 32831

Two options:

  1. Redeclare your mouseover and mouseleave event handlers
  2. Instead of doing off, test a condition in your handlers

Upvotes: 1

Related Questions