我有看起来像这样的简单 html:
<div class="img">
<a target="_blank" href="kl_big.htm" id="turn-of-cloth-01_lg">
<img src="images/galery/turn-of-cloth-01_lg.jpg" width="110" height="90" />
</a>
<div class="desc">Add a description of the image here</div>
</div>
我有 20 组具有不同 id 的这个 div,现在这个 href id 和这个
$(document).ready(function(){
$('a').click(function (event){
event.preventDefault();
var linkID =$(this).attr("id");
});
});
我不知道 img 对象 id 是什么,但我需要获取它的 src 值。我试过这样的Jquery:
var imgSrcVal = $(this).siblings("img").attr("src");
但没有结果,也在点击事件中尝试过,但再次没有结果:
imgSrcVal = this.nextSibling.src;
我在这里做错了什么?