Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Pulling an image caption

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #158350
    jony
    Participant
    // Set the title
            if(link.attr('title')){
                var titleWrap = $('<span>', { 'class': 'lightbox-title' });
                titleWrap.text(link.attr('title'));
                $('.lightbox-title-wrap').html(titleWrap);
            } else {
                $('.lightbox-title-wrap').html('');
            }
        },
    

    Using this jquery, my captions are being pulled from the title attribute of my images:

    <a href="img/LargeImage.jpg" class="lightbox" title="Image Caption Here">
    <img src="img/Thumb.jpg" ></a>
    

    This does not allow for HTML captions (i.e. adding a Facebook Like button for every image when in the Lightbox).

    I’m looking for a way to pull the caption based on the div class, similar to this:

    <a href="img/LargeImage.jpg" class="lightbox" title="ImageCaption1">
        <img src="img/Thumb.jpg" ></a>
    <a href="img/LargeImage.jpg" class="lightbox" title="ImageCaption2">
        <img src="img/Thumb.jpg" ></a>
    <a href="img/LargeImage.jpg" class="lightbox" title="ImageCaption3">
        <img src="img/Thumb.jpg" ></a>
    
    
    
    <div id="ImageCaption1" class="html-caption">
      This is my caption for image 1
    </div>
    <div id="ImageCaption2" class="html-caption">
      This is my caption for image 3
    </div>
    <div id="ImageCaption3" class="html-caption">
      This is my caption for image 3
    </div>
    

    Any suggestions?

    Thank you!

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.