/    Sign up×
Community /Pin to ProfileBookmark

How to ‘setTimeout’ function to javascript

Hello,
I would be very grateful for some help on adding ‘setTimeout’ function to javascript below. Need to create a delay (say 500 milliseconds) on images appearing when you mouseover the list of names. I have no .js knowledge.

This is the javascript as is:

[code]<script type=”text/javascript”>
$(document).ready(function() {

$(“.infoPanel li a img”).hide();

$(“.infoPanel li a”).eq(0).addClass(“current”);
$(“a.current”).next().show();
$(“.infoPanel li a.current img”).show();

$(“.infoLink”).mouseover(function() {
if (this.className.indexOf(“current”) == -1) {
$(“a.current”).next().hide();
$(“.infoPanel li a.current img”).hide();
$(“a.current”).removeClass(“current”);
$(this).addClass(“current”);
$(“a.current”).next().show();
$(“.infoPanel li a.current img”).show();
}
});

});
</script>[/code]

and this is the bit if html it effects:

[code]
<ul class=”infoPanel”>
<li><a class=”infoLink” href=”#url”><span>Paula Rego</span></a>
<div class=”img”><img src=”assets/projects/P_Rego.jpg” alt=”” />
<div class=”text”><p>Publisher: Marlborough Gallery<br />
<a href=” http://www.marlboroughgallery.com/galleries/graphics/artists/paula-rego/graphics” title=”www.marlboroughgallery.com” target=”_blank” rel=”external”>www.marlboroughgallery.com</a></p>
</div></div>
</li>
</ul>
[/code]

Any help will be very much appreciated..

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@acestuffFeb 13.2012 — Well the code is a bit of a mess 2bh but something along these lines will probably work:
[CODE]

$(".infoLink").mouseover(function() {
window.setTimeout(
function() {
if (this.className.indexOf("current") == -1) {
$("a.current").next().hide();
$(".infoPanel li a.current img").hide();
$("a.current").removeClass("current");
$(this).addClass("current");
$("a.current").next().show();
$(".infoPanel li a.current img").show();
}
},
500
});

[/CODE]


(Not tested!)
×

Success!

Help @FrankieL spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...