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 7974389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:21:18+00:00 2026-06-04T08:21:18+00:00

I am setting the title attribute of an element, and firing Fancybox, using this

  • 0

I am setting the title attribute of an element, and firing Fancybox, using this code:

var caption = jQuery('.fancybox').siblings('p.wp-caption-text').html();

jQuery('.fancybox').attr({ title:caption, 'data-fancybox-group': 'gallery1'}).fancybox();

This works fine when there is only one .fancybox link on a page, but the problem of course is that I want to use galleries.

The above sets the variable to the first instance on the page, so all captions are the same.

Can I do something like this instead?:

jQuery('.fancybox').attr({ title:'jQuery(this).siblings('p.wp-caption-text').html();', 'data-fancybox-group': 'gallery1'}).fancybox();

Please excuse my lack of coding skills, but I am hoping it is a simple question for someone more familiar with jQuery.

The page in progress: http://professorleonidas.com/wordpress/formacao/

  • 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-04T08:21:19+00:00Added an answer on June 4, 2026 at 8:21 am

    Apply to each one individually:

    var caption;
    $('.fancybox').each(function(i, elem){
        // Grab the caption text
        caption = $(elem).siblings('p.wp-caption-text').html();
    
        // Set the attributes and initialize fancybox
        $(elem).attr({ title:caption, 'data-fancybox-group': 'gallery1'}).fancybox();
    });
    

    The point of your ‘data-fancybox-group’ attribute isn’t clear from your question, but the above code will apply gallery1 as its value to all matched elements with class fancybox.

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When setting the title attribute in Zend_Form, this is not being translated. (Label &
Using a navigation controller, I am pushing a new view and setting the title
As the title suggests... I'm setting up a superfish menu using the Wordpress CSS
I'm using XslCompiledTranform to transform XML/XSL. This is my test XSL: <span title={./tooltip} anattribute={./tooltip}>
I have the following file: <html> <head> <title></title> <link rel=css type=text/css href=/empty.css title=css />
I have a div that I'm setting a title attribute on: <div id=test title=Test
As you can understand from title, i modified Settings.cs file.Added some properties, some code
We're using a Oracle Text CTXSYS.CONTEXT index to index about half a million rows
I'm just starting to get into JQuery so I apologize in advance if this
Setting the src attribute of an IFrame to data:application/pdf;base64, isn't working for me, any

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.