orange
orange

Reputation: 5405

jQuery isn't loading function on hover

I have the following code: http://jsfiddle.net/7pM2b/167/

This is my jQuery code:

    $('#change_opacity').hover(function(){
    $(this).trigger('startRumble');
    }, function(){
    $(this).trigger('stopRumble');
    });

What I am trying to achieve is that on hover I want the image to shake, I'm using the jRumble library to do this "shaking" but I can't seem to get on hover working. What am I missing?

Upvotes: 0

Views: 68

Answers (3)

Kaizen Programmer
Kaizen Programmer

Reputation: 3818

DEMO

This works:

$(function () {
    $('#change_opacity').jrumble();

    $('#change_opacity').hover(function () {
        $(this).trigger('startRumble');
    }, function () {
        $(this).trigger('stopRumble');
    });
}

Upvotes: 1

km6zla
km6zla

Reputation: 4877

Did you initialize jRumble on the element?

$('#change_opacity').jrumble();

That needs to be done before you trigger(startRumble).

This is according to their site;

Upvotes: 0

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

jQuery 'trigger' is designed to trigger BUILT-IN events, not to call functions.

I would assume you'd use something like this:

$('#change_opacity').hover(function(){
    startRumble(this)
}

Upvotes: 2

Related Questions