【发布时间】:2012-01-09 00:26:01
【问题描述】:
当点击文本“查看更多”时,我正在使用下面的脚本来刷新 div。 div 从 rotate.php 文件中加载一堆随机图像。但由于某种原因,我应用的 jquery 悬停效果在 div 刷新后不再起作用。我确实尝试将 jquery 悬停脚本添加到 rotate.php 文件中,但这会阻止刷新脚本工作...... :S 有人对如何解决这个问题有任何想法吗? :)
<div class="headingtext">
<script type='text/javascript'>
$(function() {
$("#refresh").click(function(evt) {
$(".feature").load("rotate.php")
evt.preventDefault();
})
})
</script><a id="refresh" href="#">View More</a>
</div>
<div class="feature">
<?php include('rotate.php') ?>
</div>
我已应用于图像的 jquery,但刷新后停止工作:
$(document).ready(function(){
$(".feature img").hover(function() {
$(this).stop().animate({opacity: "0.5"}, 'slow');
},
function() {
$(this).stop().animate({opacity: "1"}, 'slow');
});
});
PHP (rotate.php):
<?php
$random = "random.txt";
$fp = file($random);
shuffle($fp);
$keys = array_rand($fp, 3);
for ($i = 0; $i < 3; $i++):
$rl = $fp[$keys[$i]];
echo $rl;
endfor;
?>
【问题讨论】: