當單擊文本'view more'時,我使用下面的腳本刷新div。該div從rotate.php文件加載一堆隨機圖像。由於某種原因,我已經應用的jquery懸停效果在div被刷新後不再有效。我曾嘗試將jquery懸停腳本添加到rotate.php文件,但這會停止正在工作的刷新腳本...:S有沒有人有關於如何解決此問題的任何想法? :)jQuery刷新停止jQuery從工作中懸停
<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;
?>
謝謝〜! :D on函數實際上並不適用於我,所以我只會暫時使用live :) – Jess
函數「on」已添加到1.7版中;) – TeChn4K