Solved

Make carousel images clickable - jQuery

Posted on 2014-12-20
8
99 Views
Last Modified: 2014-12-20
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
0
Comment
Question by:knowlton
  • 5
  • 3
8 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40511002
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

0
 
LVL 5

Author Comment

by:knowlton
ID: 40511054
I am sorry...what I meant to say was....when you click on the image...it takes you to another URL.... like yahoo.com
0
 
LVL 5

Author Comment

by:knowlton
ID: 40511055
I put an alert(  ) inside the function above and it is not firing.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40511067
not sure where you put the code, it work fine for me...
try this one :
    $(document).on("click", "img.fotorama__img", function(event) {
           var $img = $(this);
           var img = $(this).get(0);
           alert($(this).closest("a").attr("href"));
           location.href = $(this).closest("a").attr("href");
    });

Open in new window

0
 
LVL 5

Author Comment

by:knowlton
ID: 40511073
Okay...the second function worked.  Thank you.

How can I determine if

img.currentSrc

contains "1.jpg" or "2.jpg", etc.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40511129
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
0
 
LVL 5

Author Comment

by:knowlton
ID: 40511135
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

0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 40511139
Excellent answer...and fast!  Thanks!
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question