I have a working script like this:
jQuery(document).ready(function(){
$('.video-thumb img').bind('mouseover',function(){
var new = $(this).attr('src').replace(/default.jpg/,'1.jpg');
$(this).attr('src',new);
}).bind('mouseout',function(){
var default = $(this).attr('src').replace(/[0-9].jpg/,'default.jpg');
$(this).attr('src',default);
});
});
Yeah, you guessed right. It's made to change YouTube's thumbnail on interval. However, I have no idea, how to create the interval. It now changes the thumbnail to 1.jpg, which is another thumbnail, but it should next change the image to 2.jpg in 1 second and so on.
The whole snippet should probably be written from scratch. Advice?
Hope you understood :-D
EDIT: I changed the variable-names from finnish words, I don't use them. Just in this example.
Martti Laine
new and default are reserved words in javascript. You cannot use them.
To create an interval you should use
setInterval
:[See it in action]
Thanks guys for great answers! (Un)fortunately I already created this via jQuery's Timers-plugin. Here's my working code:
You can see my answer working here:
HTML
JavaScript