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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:55:19+00:00 2026-05-31T21:55:19+00:00

I try get a my attribute inside Fancybox, and I get when I use

  • 0

I try get a my attribute inside Fancybox, and I get when I use href, but if I try get my attribute I get just “undefined”.

<a class="grouped_elements" rel="Group1" id="@item.Id" private="@item.Private" title="@item.Title" href="/Image/ShowFile/@item.Id">
                <img src="/Image/ShowThumb/@item.Id" alt="@item.Title"  /></a></div>

function formatTitle(title, currentArray, currentIndex, currentOpts) {

                var titlenormal = '<input type="hidden" id="idPhoto" value="' + currentArray[currentIndex].id + '">' +
                    '<span id="fancybox-title-over">' +
                    '<div id="boxComment" style="position:relative;"><div style="white-space: nowrap;"><div style="float: left;">' + title + '</div><div id="star" style="width:100%">&nbsp;</div></div>';

                alert($(this).attr("href"));



                return titlenormal;

            }
  • 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-05-31T21:55:20+00:00Added an answer on May 31, 2026 at 9:55 pm

    if you set the option titleFormat inside fancybox like

    $(".fancybox").fancybox({
     'titleFormat': formatTitle
    });
    

    then your function formatTitle works and alerts the href attribute value.

    you may also use this.href instead

    EDIT: March 23, 2012 – 12:30pm PT in response to comments.

    I guess you were not clear enough to specify which attribute to wanted to get.

    Anyways, alert($(this).attr("href")); works because href is, at this point, a jQuery object inside the fancybox function while private is not.

    As a workaround, try this instead:

    alert($(".grouped_elements").eq(currentIndex).attr('private'));
    

    within your formatTitle function like:

     function formatTitle(title, currentArray, currentIndex, currentOpts) {
      var titlenormal = '<input type="hidden" id="idPhoto" value="' + currentArray[currentIndex].id + '">' +
      '<span id="fancybox-title-over">' +
      '<div id="boxComment" style="position:relative;"><div style="white-space: nowrap;"><div style="float: left;">este es ' + title + '</div><div id="star" style="width:100%">&nbsp;</div></div>';
      alert($(".grouped_elements").eq(currentIndex).attr('private'));
      return titlenormal;
     }
    

    you could also use the onComplete callback instead to get the attribute private like:

    'onComplete': function(currentArray, currentIndex){
      alert($(".grouped_elements").eq(currentIndex).attr('private'));
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

as the title says, I keep getting undefined when I try to get the
I am trying to get an attribute value from an XML file, but my
When i use command button to redirect to pages, inside my project, u just
I try to get an attribute of a div element using jQUery 1.6.2 html
I try get the mp3 flash player to work with my javascript on all
I try to get to a page straight from Bash at http://www.ocwconsortium.org/ . The
I try to get all WPF window controls collections. In other words i try
I try to get the name of executable name of all of my launched
I try to get the last modification date of a file: NSFileManager *fm =
I try to get this following url using the downloadURL function as follows: http://www.ncbi.nlm.nih.gov/nuccore/27884304

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.