请有人把我从我的痛苦中解脱出来……我一小时又一小时地倾注于此……
我(这是缩写)一直在创建一个函数,它使用 append 将框添加到页面。问题是一旦它们被添加,fadeIn 函数就不起作用。 但是,如果我将元素硬编码到页面,它将起作用:
这是我的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>