首页javascriptrelationjQuery Selector - 如何只选择包含在链接中的图片

jQuery Selector - 如何只选择包含在链接中的图片

我们想知道如何只选择包含在链接中的图片。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.5.2.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $result = $("a > #MyImage");
    console.log($result.length);
});
</script>
</head>
<body>
  <a href='' ><img id="MyImage"></a>

</body>
</html>