Javascript Noob: How to emulate slideshow on front page by automatically cycling through existing hover states of main page links?

I wouldn't try to emulate the hover state by manually triggering mouseover Instead of making your script cause a hover, try to make your script do the same thing that hover does You already have the following for the hover function: $(this). Hover(function(){ ... }) Instead, lift out that anonymous function, like this: function onImageHover(link) { ... } $(this). Hover(function() { onImageCursor($(this)); }) And then in your rotate script, you can also call onImageHover for the same effect.

I could have written line 2 above as just $(this). Hover(onImageCursor) but I'm passing the object as a reference, so that I don't have to hack away with apply calls in order to create the same effect in rotate Other than that; in your current script, each time rotate is called, it runs the same code for all lilevel1 links. You just want to show the following, so you have to use a cursor of some kind to keep track of where in the rotation you are: var rotateCursor = -1; var imageCount = 4; function rotate() { rotateCursor++; if(rotateCursor >= imageCount) rotateCursor = 0; onImageHover( $('.

Lilevel1 a'). Eq(rotateCursor) ); }.

I wouldn't try to emulate the hover state by manually triggering mouseover. Instead of making your script cause a hover, try to make your script do the same thing that hover does. You already have the following for the hover function: $(this).

Hover(function(){ ... }); Instead, lift out that anonymous function, like this: function onImageHover(link) { ... } $(this). Hover(function() { onImageCursor($(this)); }); And then in your rotate script, you can also call onImageHover for the same effect. I could have written line 2 above as just $(this).

Hover(onImageCursor) but I'm passing the object as a reference, so that I don't have to hack away with apply calls in order to create the same effect in rotate. Other than that; in your current script, each time rotate is called, it runs the same code for all lilevel1 links. You just want to show the following, so you have to use a cursor of some kind to keep track of where in the rotation you are: var rotateCursor = -1; var imageCount = 4; function rotate() { rotateCursor++; if(rotateCursor >= imageCount) rotateCursor = 0; onImageHover( $('.

Lilevel1 a'). Eq(rotateCursor) ); }.

I see. I'll try to work on this and see how it goes. I'll def'ly keep you posted.

Thanks much! – Zildjoms Mar 25 '10 at 18:47.

(sorry, I can't fit this into the comment box. This is a response to the first answer by David Hedlund) i'm trying to get past the first step, lifting out the anonymous function. I can't make it work.

Help: original code: $('#li1flnk'). Attr('id', 'li1fa'); $('#li1tlnk'). Attr('id', 'li1ta'); $('#li1alnk').

Attr('id', 'li1aa'); $('#li1clnk'). Attr('id', 'li1ca'); $('li. Lilevel1 a').

Append(''). Each(function () { var $span = $('> span. Hover', this).

Css('display', 'none'); $(this). Hover(function () { $span. Stop(false, true).

FadeIn('slow'); }, function () { $span. Stop(false, true). FadeOut('slow'); }); }); supposedly "lifted out" code $('#li1flnk').

Attr('id', 'li1fa'); $('#li1tlnk'). Attr('id', 'li1ta'); $('#li1alnk'). Attr('id', 'li1aa'); $('#li1clnk').

Attr('id', 'li1ca'); $('li. Lilevel1 a'). Append('').

Each(function () { var $span = $('> span. Hover', this). Css('display', 'none'); $(this).

Hover(onImageHover($(this));); }); function onImageHover(link) { { $span. Stop(false, true). FadeIn('slow'); }, { $span.

Stop(false, true). FadeOut('slow'); } } what am I doing wrong? Soo sorry am new to all this..

I finally made it work. If you guys could suggest how I could improve efficiency of the code then please do so. Thanks so much.

This script is at work at s5ent.com.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions