The lightbox has an alternative mode that makes it usable without the need of existing elements in the html.

To use the example from the beginning, we first open the lightbox with a single image. Initializing the lightbox with the API-mode will directly return the lightbox-object.

var lb = $.bbLightbox({ type: 'image', src: 'image.png' });

lb.open();

To open the lightbox with any content, the function has to be called with an object that defines the type and the necessary attributes.