I have a sort of silly website request – they want the hover states to animate because they think no one will know there are links there otherwise…
Anyway… I created a slideshow to show the effect I’m trying to create – but now I can’t get it to work with the jQuery code. I found what I thought was an answer here: Trying to loop between CSS classes/hover states – Jquery
but even incorporating this new code, the animation/toggle doesn’t work.
I assume I’m missing something obvious – can anyone help?
Here’s the slideshow version to show effect I’m going for:
http://test.fatcat-studios.com/gtm/index.html
but I want to do this with jQuery so when you interact with it, the correct hover state shows upon actual mouse over.
And here’s my jQuery code:
$(function() {
var doToggle = true;
$('a.res').removeClass('hover');
$('a.com').addClass('hover');
var tid = setInterval( function() {
if (doToggle) $('a.res, a.com').toggleClass('hover');
}, 2000);
setTimeout(function() {
if (tid) clearInterval(tid);
$('a.res,a.com').removeClass('hover');
}, 30000); // stop toggling after 30 seconds
$('a.res,a.com').hover( function() {
doToggle = false;
}, function() {
doToggle = true;
});
});
Any help is much appreciated! Let me know if there’s more info needed.
Haikukitty
Try this :