画像のリストを取得するために jQuery Ajax 呼び出しを使用しています。現在は動作しますが、XML ファイル内のすべての画像を取得します。すべてのサブジェクトのすべての画像を表示するのではなく、特定のサブジェクトのすべての画像を取得するようにコードを変更するにはどうすればよいですか。
したがって、「件名」タグごとに、すべての「画像」タグをリストしたいと思います。
jQueryで11行目を変更する必要があることはわかっています
$(data).find('image').each(function(){
完全なjQuery機能
<script type="text/javascript">
$("#ARTH1520").live('pagebeforecreate', function() {
$.get('data/ARTH1520.xml',function(data){
$('.content').empty();
$(data).find('subject').each(function(){
var $subject = $(this);
var html = '<div class="data">';
html += '<div data-role="collapsible" data-collapsed="true" data-theme="b"><h3>' + $subject.attr('title') + '</h3>';
html += '<ul data-role="listview">';
$(data).find('image').each(function(){
var $image = $(this);
html += '<li><img src="' + $image.attr('img') + '" />';
html += '<h3>' + $image.attr('title') + '</h3><p>' + $image.attr('description') + '</p></li>';
});
html += '</ul>';
html += '</div></div>';
$('#result').append(html).trigger( "create" );
$('#result .loading').remove();
});
});
});
</script>
XML ファイル
<subjects>
<subject title="At History One">
<images>
<image title="Mona Lisa" img="lisa.jpg" id="s1i1" description="image 1"></image>
<image title="" img="" id="s1i2" description=""></image>
</images>
</subject>
<subject title="Renaissance">
<images>
<image title="" img="" id="s1i3" description=""></image>
</images>
</subject>