画像が読み込まれたときにのみ画像を読み込みたい。
画像が読み込まれる前にクラス「hidden」が削除されるため、これは機能しません。
$(function(){
$('#nowplaying').load('nowplaying.php', function() {
$('#images').removeClass('hidden');
}
)});
どうすればよいですか?
編集:ここに私のコードがあります:
index.php には次のものがあります。
<script type="text/javascript">
$(function(){
$('#nowplaying').load('nowplaying.php');
});
var auto_refresh = setInterval(
function ()
{
$('#nowplaying').load('nowplaying.php').fadeIn("slow");
}, 10000); // refresh every 10000 milliseconds
</script>
nowplaying.php には、次の div があります。
echo "<div id="images">;
foreach ($jpg_files as $file) {
if (file_exists($cover_path."\\\\".$file) && $file!="f.jpg") {
$file = urlencode($file);
echo "<a href=\"getimage.php?img=".$file."\" target=\"_blank\">
<img src=\"getimage.php?img=".$file."&p=".$cover_path."\" /></a>";
echo " ";
}
echo "</div>;
div id #images の画像がロードされたときにのみ表示したい (ブラウザで画像が作成されているのをユーザーに見せたくない)。
どうやってするの?
誰かが waitForImages の簡単な例を送ることができますか? 私にはまったくうまくいきません。
EDIT 12-12-15:これは機能しています:
<img style="display:none;" src="big3.jpg">
<script type="text/javascript">
$('img').load(function(){
$(this).css({'display':'block'})
});
</script>
しかし、これは機能していません。なぜですか?:
<div style="display:none;">
<img src="big3.jpg">
</div>
<script type="text/javascript">
$('div').load(function(){
$(this).css({'display':'block'})
});
</script>
理由はまだわかりません。しかし、これは img に通常の src がある場合に機能します: div の下:
<script type="text/javascript">
$(document).ready(function(){
$("div.images").hide();
$("div.images").find("img").load(function(){
$(this).closest("div.images").show();
});
});
</script>
今ここに私の大きな問題があります:私の画像srcはスクリプトを呼び出しています:
<img src=\"getimage.php?img=".$file."\" />";
どうすればこれを機能させることができますか?