Reputation: 11302
How can I select the src attr from the zoom span?
$(".gallery span.zoom").click(function() {
// var imgPath = $(this).parent()......attr("src");
// alert(imgPath);
return false;
});
<ul class="gallery">
<li id="li-1">
<img src="002171/tn/001.jpg" alt="image" />
<span class="delete"></span>
<span class="zoom"></span>
<em>hello world</em>
</li>
</ul>
Upvotes: 0
Views: 81
Reputation: 272006
$(".gallery span.zoom").click(function() {
alert($(this).parent().find('img').attr('src'));
return false;
});
Upvotes: 1
Reputation: 65254
try:
$(".gallery span.zoom").click(function() {
var imgPath = $(this).siblings('img').attr("src");
alert(imgPath);
return false;
});
Upvotes: 3