Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery open anchor link from function

Say I have an anchor link like:

<a id="page-contact" rel="shadowbox;width=640;height=400" href="/contact.php">link here</a>

How would I be able to open it from jquery i.e.

jQuery('#page-contact').click();

Obviously that calls the .click event but doesn't do the href if that makes sense.

The object of this is to actually open a lightbox not to change the page like window.location

like image 464
Shane Avatar asked Dec 03 '25 18:12

Shane


1 Answers

To change your current page to the href attribute of that element:

document.location.href = $('#page-contact').attr('href');

EDIT now that we have the real question, I think you can do this:

var obj = Shadowbox.setup('#page-contact');
Shadowbox.open(obj);
like image 86
Alnitak Avatar answered Dec 05 '25 07:12

Alnitak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!