jquery - Fancybox gallery with images in different places -
i have (html) page image gallery (all images together) , 1 separate image.
i put images image gallery in a
<div id="imagegallery"> i put separate image in a
<div id="separateimage"> and have javascript
$('#imagegallery a').fancybox(); $('#separateimage a').fancybox(); fancybox works fine on both, image gallery , separate image. can cycle through image gallery, however, separate image not part of cycle. how can make cycles through images: image gallery , separate image?
i tried adding
rel="gallery" to anchors explained @ https://www.inkling.com/read/javascript-jquery-david-sawyer-mcfarland-2nd/chapter-7/advanced-gallery-with-jquery
but apparently works if images in same div (id)!?
the issue binding fancybox 2 different selectors :
$('#imagegallery a') , $('#separateimage a') in order make gallery, elements whether within same div or not, need use same selector (fancybox v2.x)
so without having hard-code manually each element of each separated div, :
$("#imagegallery a, #separateimage a") .addclass("fancybox") .attr("rel", "gallery") .fancybox({ //api options padding: 8 // example }); now elements regardless position share same class , rel attribute.
see jsfiddle
Comments
Post a Comment