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/
Apply to each one individually:
The point of your ‘data-fancybox-group’ attribute isn’t clear from your question, but the above code will apply
gallery1as its value to all matched elements with classfancybox.Cheers