Fancybox dynamic image load from var
Fancybox dynamic image load from var I am using this code to grab a class value from an a href: <a href="" class="images/success.jpg">Click to get image</a> <script> $("#myMenu a").bind("click", function() { var myPic = $(this).attr("class"); alert(myPic); }); </script> Everything working normal and smooth. Now I am using fancybox to load images and I have this code of fancy box that works normal also: $.fancybox.open('images/success.jpg'); I am trying to pass the variable myPic into fancybox code but I cant make it. So far I have tried this: $.fancybox.open(myPic); $.fancybox.open('myPic'); Is there any possibility to make it work? 1 Answer 1 There are always easier or more complicated ways to achieve the same result. Having a class="images/success.jpg" is not semantically appropriate. The easie...