jQuery fancybox append image source to href -
I am using the fancybox plugin on my site. I want to use jQuery to locate the image source and keep it in href.
My html looks like this:
& lt; Div class = "item" & gt; & Lt; Img src = "img / sam_skirrow_the_moment_3.jpg" class = "item_img" /> & Lt; / Div & gt; And I'm using jquery to attach the fancybox code:
$ ('& lt; class = "fancybox" href = " [Image Source] "& gt; & lt; / a & gt; ') appendTo (.' Items'). Do I need to capture IMG src and add it as source of href ?? Maybe something like that? $ ('& lt; img & gt;'). Attr ('src'). Attachment ('. Fancybox'); So my question is: How can I use jQuery to get an image source and add it to "href"? I.e. one href = "[IMAGE of SRC]"
If you have more than one and Lieutenant is; and & Lt; / Div & gt; etc. Then you can use it as a .each () and .wrap () methods: $ (".meg img" ) .each (function () {var newHref = $ (this) .attr ("src"); $ (this) .vp ("& lt; class = 'fancybox' rel = 'gallery' href = '" + newHref + "'/";);}); Of course, you still need to force fancybox in selector .fancybox $ (".fancybox") is. Fancy box (); View
Comments
Post a Comment