Skip to content Skip to sidebar Skip to footer

This.id Inside Of Fancybox

I'm attempting to have a fancybox pop up with a facebook LIKE button in the title that links to the unique page based on which item is clicked. All of the images are id'ed with a u

Solution 1:

You're trying to access this inside a different function to the .each function, so this refers to something else. You can copy this into a variable though, for safe access inside the inner function:

$("a.fancybox").each(function() {
    var element = this;
    $(this).fancybox({
        'titleFormat'   : function() {
            var astring = '<span>' + element.id + '</span>';
            return astring;
        }
    });
});

Post a Comment for "This.id Inside Of Fancybox"