jQuery如何在href中选择img src

use*_*898 0 jquery siblings

我有简单的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>
Run Code Online (Sandbox Code Playgroud)

我有20套这个div与不同的ID,现在href id im gtting与此

$(document).ready(function(){
    $('a').click(function (event){

        event.preventDefault();
        var linkID =$(this).attr("id"); 
    });
});
Run Code Online (Sandbox Code Playgroud)

我不知道什么是img对象id,但我需要得到它的src值.我试着用Jquery这样:

var imgSrcVal = $(this).siblings("img").attr("src");
Run Code Online (Sandbox Code Playgroud)

但是如果没有结果,也可以在click事件中尝试但是没有结果:

imgSrcVal = this.nextSibling.src;   
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

Cᴏʀ*_*ᴏʀʏ 6

<img>不是兄弟姐妹,而是锚的孩子.

试试这个:

$('a').click(function (event){
    var linkID = $(this).attr("id"); 
    var imgSrcVal = $('img', this).attr("src");
    //alert(imgSrcVal);
    return false;
})
Run Code Online (Sandbox Code Playgroud)

简单的JSFiddle演示.