誰か私を悲惨な状況から解放してください....私はこれに何時間も注いでいます...
私は(これは省略されています)追加を使用してページにボックスを追加する関数を作成しています。問題は、それらが追加されると、フェードイン機能が機能しないことです。 ただし、要素をページにハードコーディングすると機能します。
これが私のJavaScriptです:
//Loop through the images and print them to the page
for (var i=0; i < totalBoxes; i++){
//$("p").add(arr).appendTo('#bg');
$.ajax({
url: "random.php?no=",
cache: false,
success: function(html){
$(html).fadeIn(html).appendTo('#bg');
}
});
}
//Choose the image to be faded in
$(".pf-box img").hover(function(){
var largePath = $(this).attr("rel");
$(this).fadeOut("slow", function() {
$(this).attr({ src: largePath }).fadeIn("slow");
});
return false;
});
random.php は文字通り多くのボックスを印刷します...ここに印刷されたサンプルがあります:
<div class="pf-box" style="">
<a href="#">
This is where the image is printed with the rel attribute on the image tag. (stackoverflow didnt allow the posting of the img tag because its my first post)
</a>
</div>