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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:15:45+00:00 2026-05-25T11:15:45+00:00

I am trying to load content in from sub pages and then add the

  • 0

I am trying to load content in from sub pages and then add the rel attribute for a gallery required by the prettyPhoto plug in. After the script runs the rel has only been added to the last set of images.\

HTML

<div class="prettyphotothumb">
    <ul class="navsub">
    <li><a href="album.html"><img src="images/thumbnail.jpg" alt="" />Album</a></li>
    <li><a href="blarg.html"><img src="images/thumbnail.jpg" alt="" />Blarg</a></li>
    <li><a href="test.html"><img src="images/thumbnail.jpg" alt="" />Test</a></li>
    </ul>
</div>

JS

if($('div.prettyphotothumb').length > 0) {
    $('div.prettyphotothumb a').each(function() {
        var pageLink = $(this);
        var albumTitle = $(pageLink).text();
        var album = $('<div class="album"></div>').appendTo( $(pageLink).parent());

        $('.album').load(this.href+' .prettyphotoalbum p > *',null,function(){  
            album.children('a').attr('rel','prettyPhoto['+albumTitle+']');
        });

        $('a[rel^="prettyPhoto"]').live("click",function() {
            $.prettyPhoto.open($(this).attr("href"),"","");
            return false;
        });         

    }); 
}
  • 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-25T11:15:45+00:00Added an answer on May 25, 2026 at 11:15 am

    As you iterate using each, you’re adding a <div class="album"> on each iteration:

    var album = $('<div class="album"></div>').appendTo( $(pageLink).parent());
    

    And then right below that:

    $('.album').load(//...
    

    On the first iteration, $('.album').length will be one, on the second it will be two, etc. The final iteration will end up calling .load('test.html .prettyphotoalbum p > *', ... on all three <div class="album"> elements that you’ve added.

    I think you want to just bind the load to the thing you just created:

    // Use album rather than $('.album')
    album.load(this.href+' .prettyphotoalbum p > *',null,function(){  
        album.children('a').attr('rel','prettyPhoto['+albumTitle+']');
    });
    

    Also, you only need one .live call so move this:

    $('a[rel^="prettyPhoto"]').live("click",function() {
        $.prettyPhoto.open($(this).attr("href"),"","");
        return false;
    });
    

    outside the .each. So something like this should work better:

    if($('div.prettyphotothumb').length > 0) {
        $('div.prettyphotothumb a').each(function() { 
            var pageLink   = $(this);
            var albumTitle = $(pageLink).text();
            var album      = $('<div class="album"></div>').appendTo($(pageLink).parent());
    
            album.load(this.href+' .prettyphotoalbum p > *', null, function() { 
                album.children('a').attr('rel', 'prettyPhoto[' + albumTitle + ']');
            });
        });
    
        $('a[rel^="prettyPhoto"]').live("click", function() {
            $.prettyPhoto.open($(this).attr("href"), "", "");
            return false;    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load new content to my page from database when user scrolls
Trying to load content into a div, then on click load the previous content
I am trying to load html content from another page via .load(). For example:
I've been trying to load masterpage content from database (based on a TargetCode in
I am trying load content from another url using pushstate/html5... The content I am
I'm trying to load content from one of my sites in another: <div id='include-from-outside'></div>
I'm trying to load in content from a database and allow the user to
I am trying to batch load some dummy content from a CSV file into
I am trying to load content from a remote URL in my php code.
How can I achieve this? I am trying to load content from the database

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.