April 3, 2012

jQuery-Galleriffic, get title of current image

Question by enne87

I use the wonderful jQuery-plugin Galleriffic to display image galeries. Now this works great, but what I want to achieve is to get the title of the image that is currently displayed. If I put the mouse cursor over the image, it shows the title. Unfortunately, I haven’t managed yet to get the title via jQuery.

Any help is very appreciated.

Thanks,

enne

Edit: Here’s the link to the plug-in: http://www.twospy.com/galleriffic/

Here is also some code. I’m not sure but I think the image is shown as background-image in the following container:

<div id="slideshow" class="slideshow">
</div>

I use the following javascript code:

 $('div.slideshow').hover(
         function () {
        //Get the title here    
          },
          function () {  
          }
  );

Ok, firebug shows me this code:

<div id="loading" class="loader" style="display: none;"></div>
    <div id="slideshow" class="slideshow">
      <div id="slide-container">
           <span class="image-wrapper current" style="opacity: 1;">
            <a class="advance-link" title="Chrysanthemum" href="#2" rel="history">
           <img alt="Chrysanthemum" src="http://ulc.local/sites/default/files/imagecache/preset_image_gallery_diashow/sites/default/files/Chrysanthemum_3.jpg">
          </a>
          </span>
         </div>

So here I need the “alt” attribute of the image.

Answer by Starx

You can select the current img using this selector

$('div.slideshow .current img')

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!