I have the following fancybox code:
$('.fancybox').fancybox({
'autoScale' : false,
'href' : $('.fancybox').attr('id'),
'type':'iframe',
'padding' : 0,
'closeClick' : false,
//some other callbacks etc
the problem is I have twenty different A tag id's on the page and I want the fancybox href attribute to take the id of the clicked element, ie the one that triggered the event.
I have tried several things, none of them have worked!
'href' : $(this).attr('id'),
'href' : $(this.element).attr('id'),
This seems so simple but anytime I plug in 'this' or similar nothing works.
id
attribute and thehref
attribute? ... let html do what it does better (without overusing jQuery) you can have 20 different IDs in your<a>
tags but all of them can share the sameclass="fancybox"
so your script above will work seamlessly and without over complicating things. – Adhamhref
API option and fancybox will take it from thehref
attribute in the<a>
tag. – Adham