Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:51:54+00:00 2026-06-17T10:51:54+00:00

On each page load i am changing a image. I found this plugin which

  • 0

On each page load i am changing a image. I found this plugin which is doing a great work.

(function($){

    $.randomImage = {
        defaults: {

            //you can change these defaults to your own preferences.
            path: '/templates/default/images/', //change this to the path of your images
            myImages: ['fab_ad1.jpg', 'fab_ad2.jpg', 'fab_ad3.jpg'] //put image names in this bracket. ex: 'harold.jpg', 'maude.jpg', 'etc'

        }           
    }

    $.fn.extend({
            randomImage:function(config) {

                var config = $.extend({}, $.randomImage.defaults, config); 

                 return this.each(function() {

                        var imageNames = config.myImages;

                        //get size of array, randomize a number from this
                        // use this number as the array index

                        var imageNamesSize = imageNames.length;

                        var lotteryNumber = Math.floor(Math.random()*imageNamesSize);

                        var winnerImage = imageNames[lotteryNumber];

                        var fullPath = config.path + winnerImage;


                        //put this image into DOM at class of randomImage
                        // alt tag will be image filename.
                        $(this).attr( {
                                        src: fullPath,
                                        alt: winnerImage
                                    });


                }); 
            }

    });



})(jQuery);

HTML:

<img class="shuffle" src="" alt="" onclick="chooseLink()">

Calling this function:

$('.shuffle').randomImage();

Using this feature i am displaying ads in my page. I having separate link for each ad image. When a image is clicked i am calling a javascript function and there i need to identify the image name and with respect to that i am redirecting to the separate link. In my case I dont know how to identify the image name which was clicked. Please suggest me how to identify the image name which was clicked.
Hope my Question is Clear.
Thanks in Advance !!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:51:56+00:00Added an answer on June 17, 2026 at 10:51 am

    Change

    <img class="shuffle" src="" alt="" onclick="chooseLink()">
    

    to

    <img class="shuffle" src="">
    

    And add this in your script :

    $('.shuffle').click(function(){
        var imageId = this.src.split('/').pop(); // this is the name of your image file
                                                 // It identifies the image
        // use the image 
        chooseLink(imageId);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which simply changes 4 images on each page load. <HEAD>
I am currently requesting a twitter feed on each page load (I know this
I would like to check the load speed of each page in a particular
Running some user-load tests with jmeter, and noticed that for each page load after
I'm having a problem with Symfony creating a new session on each page load,
I have three leaves in my navigation bar on this page . Each leaf
I wrote a simple javascript image rotator which picks a random image on each
Each page on my website is rendered using PHP. Each PHP file uses around
I'm trying to extract each page of a PDF as a string: import pyPdf
I need to add css height to each page dynamically with jQuery. So far

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.