/    Sign up×
Community /Pin to ProfileBookmark

Quick code change from click to a hover control

Hi All,

I have a code which works like an image gallery script, click a button/thumbnail a large image above fades in. I actually want it changed that so instead of clicking the thumbnail you just mouseover and the large image fades in.

Here is my code, I would really appreciate somebody having a look over it.
Javascript:

[CODE]$(function()
{
$(“#section_select a”).click(function()
{
var imageSource = $(this).children(“img”).attr(“src”);

$(“#image_holder”).addClass(“loading”);
$(“#image_holder h3”).remove();
showImage(imageSource);
return false;
});
});

function showImage(src)
{
$(“#image_holder img”).fadeOut(“normal”).remove();
var largeImage = new Image();
$(largeImage).load(function()
{
$(this)[0].style.display = “none”;
$(“#image_holder”).append(this).removeClass(“loading”);

$(this).fadeIn(“slow”);
});
$(largeImage).attr(“src”, src);
}
[/CODE]

HTML:

[code=html]<div id=”feature”>
<div id=”image_holder”>
<h3>Image Holder</h3>
</div>
<div id=”section_select”><ul id=”nav”><li id=”hotel”><a href=”#”>Hotel<img src=”lion2.jpg” alt=”Hotel” /></a></a></li><li id=”club”><a href=”#”>Country Club<img src=”lion3.jpg” alt=”Country Club” /></a></li><li id=”spa”><a href=”#”>Spa<img src=”lion4.jpg” alt=”Spa” /></a></li><li id=”conf”><a href=”#”>Conference &amp; Banqueting<img src=”lion5.jpg” alt=”Conference and Banqueting” /></a></li><li id=”wedding”><a href=”#”>Weddings<img src=”lion6.jpg” alt=”Weddings” /></a></li></ul>
</div>
</div>
[/code]

Thanks for taking the time to look.

Adam

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@SynergySage89Jan 23.2009 — Hi Adam,

Why are there 2 closing anchor tags here:

<i>
</i>&lt;li id="hotel"&gt;&lt;a href="#"&gt;Hotel&lt;img src="lion2.jpg" alt="Hotel" /&gt;&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
Copy linkTweet thisAlerts:
@adambauthorJan 23.2009 — Coda autocompletes tags, not used to it, coded the extra closing tag by mistake.

Ad
Copy linkTweet thisAlerts:
@Jeff_MottMar 15.2009 — To answer the original question, adamb, mostly likely all you need to do is change$("#section_select a").[color=red]click[/color](function()to$("#section_select a").[color=red]mouseover[/color](function()
×

Success!

Help @adamb 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,
)...