私は次のHTMLを持っています:
<div id="showDropZone" class="ui-droppable" style="position: absolute; z-index: 1; outline-style: none; left: 0px; width: 379px; height: 500px;">
<div id="introText" style="display: none;">Drag and drop program images here</div>
<ul class="gallery ui-helper-reset">
<li class="imgThumbLi ui-draggable imageSelected" title="File Name: drago.jpg Dimension: 225x225 Size: 7 KB" style="display: list-item;">
<img class="image" src="/myApp/2012/5/1/1335900424140/39345e7f3d12487bb6e347e786194c9b" title="File Name: drago.jpg Dimension: 225x225 Size: 7 KB">
<div class="imageInfo">
<p class="detailTitle">Logo!</p>
</div>
</li>
</ul>
</div>
</div>
私の jQuery/JS 関数では、<ul>
要素 (およびその子) を取得し、次のコードを使用して のテキスト値を<li>
簡単に見つけることができます。p.detailTitle
$("#showDropZone").find("ul").each(function() {
$(this).find("li").each(function() {
var detailTitle = $(this).find("p.detailTitle").text();
// This prints "Logo!" correctly...
alert(detailTitle);
var imageTitle = $(this).find("img").title;
var imageSrc = $(this).find("img").src;
// But these both print "undefined"...
alert(imageTitle);
alert(imageSrc);
}
}
と属性<img>
を取得するにはどうすればよいですか? 上記のコードに示されているように、現在のコードはそれらを として返します。前もって感謝します!title
src
undefined