Trying to get the url of the picture (scr) when you hover on the block
$(document).ready(function(){ $('#newSS div div').hover(function(){ var src = $(this).attr('src'); var a = '<a class="fancyimage" href="'+src+'">go</a>'; $(this).prepend('<div class="thumb_bar clearfix">'+a+'</div>'); }, function(){ $(this).children('.thumb_bar').remove(); }); }); from blocks
<div id="newSS" class="item-container"> <a class="item" href="/s/1"> <div class="thumb_container" <div class="img"> <img id="0" class="thumb" src="913.jpg"> </div> </div> <div class="item_name">name 1</div> </a> </div> <div id="newSS" class="item-container"> <a class="item" href="/s/2"> <div class="thumb_container"> <div class="img"> <img id="1" class="thumb" src="7732.jpg"> </div> </div> <div class="item_name">name 2</div> </a> </div> How to correctly pull the url of the picture?
if you do this
var src = $('#newSS div div img').attr('src'); then I get the url of the first block