views:

133

answers:

1

Hello,

Does somebody know, how to call a lightbox from an custom link?

Example:

$('#price1 a').lightBox(); //in the header

Now I want to click a custom link somewhere on the page.

<a href="#" class="price1">Link to lightBox</a>

And images in a div (until link clicked they are not visible)

<div id="price1" style="display: none;">
    <a href="../images/img1.jpg"></a>
    <a href="../images/img2.jpg"></a>
    <a href="../images/img3.jpg"></a>
</div>

Could somebody please help.

Best Regards!

A: 

You can try jQuery events binding:

$(".price1").bind("click", function() {
    $("#price1 a:first").click();
};

This way, when you click on link with class "price1", jQuery will emulate clicking on first link in div with id "price1".

Daniel Hernik
where should past this code? in the header? It doesn't work and no errors.
Jooj
In the header. Try pasting it just after "...lightbox();" line.
Daniel Hernik
I did it like you wrote but nothing...
Jooj
OK, sorry for my mistake. See my edit, the thing is you have to click on one of the links in div "#price1" (I choose first one with selector "a:first"), not just on the div.
Daniel Hernik
Wow it works! Thank you Daniel!
Jooj
You're welcome!
Daniel Hernik