I can’t seem to work out why this simple .parent() is not working.
Currently inside my div.entry I have text links and image links.
The image links always wrap img’s
And the hyperlinks are just text.
If I add this script, then all my a tags inside div.entry launch fancy box…
$(".entry a").fancybox();
So to target just the img hyperlinks (which are links to my fullsize image), I tried all of these…
$(".entry a img").parent('a').fancybox();
$(".entry a img").parent().fancybox();
$(".entry a img").closest('a').fancybox();
But none of these seem to work??
Can anyone advise on what I’m doing wrong?
Thanks
The correct way to do that would be:
but your way of doing it should also work.
What do you get if you try
console.log( $(".entry a img") )?