Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

Make carousel images clickable - jQuery

I request assistance in making the images clickable for the sequential images on the main page of my website.

Here is the live site URL:

http://www.utahkidsfoundation.com
Avatar of leakim971
leakim971
Flag of Guadeloupe image

what do that mean?

jQuery(function($) {
    $("div.fotorama__stage__shaft img.fotorama__img").click(function(event) {
           var $img = $(this);
           var img = $(this).get(0);
           // do what you want with
    });
});

Open in new window

Avatar of Tom Knowlton

ASKER

I am sorry...what I meant to say was....when you click on the image...it takes you to another URL.... like yahoo.com
I put an alert(  ) inside the function above and it is not firing.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay...the second function worked.  Thank you.

How can I determine if

img.currentSrc

contains "1.jpg" or "2.jpg", etc.
try to understand the code...
           var $img = $(this);
           var img = $(this).get(0);

so use :

$(this).attr("src")
or :
$img.attr("src")
or :
img.src
My final solution, based on leakim971's  input.

 $(document).on("click", "img.fotorama__img", function (event) {
                    var $img = $(this);
                    var img = $(this).get(0);
                
                    if (img.currentSrc.indexOf("1.jpg") >= 0) {
                        location.href = "MeetOurUtahKids.aspx";
                    }
                    if (img.currentSrc.indexOf("2.jpg") >= 0) {
                        
                        window.open("http://www.facebook.com/groups/utahkids");
                    }
                    if (img.currentSrc.indexOf("3.jpg") >= 0) {
                        location.href = "ListOfNonProfits.aspx";
                    }
                    if (img.currentSrc.indexOf("4.jpg") >= 0) {
                        location.href = "Default.aspx";
                    }
                });

Open in new window

Excellent answer...and fast!  Thanks!