Reputation: 5405
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
Reputation: 3818
This works:
$(function () {
$('#change_opacity').jrumble();
$('#change_opacity').hover(function () {
$(this).trigger('startRumble');
}, function () {
$(this).trigger('stopRumble');
});
}
Upvotes: 1
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
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