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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:06:36+00:00 2026-05-22T20:06:36+00:00

I am using ColorBox as a lightbox library. I want to use it to

  • 0

I am using ColorBox as a lightbox library. I want to use it to display hidden content for dynamic content generated with PHP.

I take this example on the website (that is the form I need, in “inline” content):

$(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});

And the HTML:

<a class='example8' href="#">Inline HTML</a>

<div style="display:none">
<div id='inline_example1' style='padding:10px; background:#fff;'> 
    <p><strong>This content comes from a hidden element on this page.</strong></p>      
    <p><strong>If you try to open a new ColorBox while it is already open, it will update itself with the new content.</strong></p> 
    <p>Updating Content Example:<br /> 
    <a class="example5" href="../content/flash.html">Click here to load new content</a></p>   
</div>
</div>

But what I can’t add (I don’t see the logic in it) like 50 javascript definitions for content that is generated in PHP. My content is generated like this:

<div class="product" id="item-1">
    <h1><a href="javascript:;" class="product-description-load">Product name</a></h1>
    Price: 10€

    <div style="display:none">
        <div id="product-description-1">Hidden description for product 1</div>
    </div>
</div>

<div class="product" id="item-2">
    <h1><a href="javascript:;" class="product-description-load">Product name</a></h1>
    Price: 10€

    <div style="display:none">
        <div id="product-description-2">Hidden description for product 2</div>
    </div>
</div>

Anyone has suggestions on how I can do it with only one function for all the products?

Thank you in advance!!!

EDIT: what I don’t want to repeat 50 times is this:

$("#item-1").colorbox({width:"50%", inline:true, href:"#product-description-1"});

Because I don’t know how many items i’ll have.

  • 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-22T20:06:37+00:00Added an answer on May 22, 2026 at 8:06 pm

    Use the rel attribute of your anchor to create a reference to the inline content.

    <div class="product" id="item-1">
        <h1><a href="javascript:;" rel="product-description-1" 
               class="product-description-load">Product name</a>
        </h1>
        Price: 10€
    
        <div style="display:none">
            <div class="product-description" id="product-description-1">
                Hidden description for product 1
            </div>
        </div>
    </div>
    

    Then bind colorbox based on class, not on id, and use a custom href function:

    $(document).ready(function() {
        $(".product-description-load").colorbox({
            width:"50%",
            inline: true,
            href: function() {
                var $element = $.colorbox.element();
                return $('div#' + $element.attr('rel')).parent().html();
            }
        });
    });
    

    Working example at http://jsfiddle.net/ce7a4/12/

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

Sidebar

Related Questions

I send form data using php in colorbox(lightbox) ifarme method. so i close auto
I am using jquery lightbox plugin colorbox ( http://colorpowered.com/colorbox/ ) and i want to
I am using a jquery lightbox plugin ( http://colorpowered.com/colorbox/ ) to load content using
I'm using the Colorbox lightbox plugin to display lightboxes with Outside HTML (Ajax) on
I'm using Colorbox to display pages in a modal window format. This plugin works
I am trying to display a hidden div in colorbox using an <a> link's
I am using colorbox to display a lightbox. The lightbox is transparent and the
I'm using Colorbox to show the html content of hidden divs on my page.
I am using colorbox.js to display some forms in a lightbox. There are multiple
I'm using Colorbox to display course info for a college (see page ). In

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.