次のjQueryコードでは:
$(document).ready(function(){
function parse(document){
$(document).find("entry").each(function(){
$("#items").append(
'<h3><a href="#">'+$(this).find('title').text()+'</a></h3>'+
'<div> '+$(this).find('summary').text()+'</div>'
);
$('#items > div').hide();
});
}
$.ajax({
type: "GET",
url: 'www.---.com', // name of file you want to parse
dataType: "xml",
success: parse,
error: function(){alert("Error: Something went wrong");}
});
//ANIMATION
$('#items h3').click(function(){
$(this).next().animate({'height':'toggle'}, 'slow', 'easeOutBounce');
});
$('#footer').click(function(){alert("Why does this work, but not the bouncing panels?")});
});
// ANIMATIONとマークされたセクションは、parse()関数内に配置すると機能しますが、非常に不安定です。上記のように、その外側に配置すると、まったく実行されません。
なんで?なぜそれが動かないのか理解しようとして、私は本当に壁に頭をぶつけています。