2017-08-16 5 views
-2

から要素を取り出す:jQueryのは、私は、HTMLのこの部分を持っている入れ子になったクラス

<div class="ThirdRowBanner"> 
    <div class="yCmsComponent col-xs-12"> 
     <div class="simple-banner-component simple-banner"> 
      <img title="sometitle" alt="somealt" src="someurl/apparel-category-banner.jpg"> 
     </div> 
    </div> 
</div> 

私はjQueryのIMGのタイトル、ALTおよびSRC要素を取得することができますどのように? imgにIDやその他のタグを追加できません。私は "ThirdRowBanner"クラスからのみ始めることができます。

+2

あなたは '$を試してみました( 'ThirdRowBanner。 ')(' IMG')を見つける' – tech2017

答えて

0

あなたはそのクラスから.findを使用することができます。

$("div.ThirdRowBanner").find("img").each(function() { 
    console.log($(this).attr("title")); 
    console.log($(this).attr("src")); 
    console.log($(this).attr("alt")); 
}); 
+0

ありがとうございました!!!!!!。 – sharkbait

関連する問題