HTML显示图像,然后等待,然后显示另一个图像

时间:2012-08-15 12:41:46

标签: php jquery html wait

我要做的就是当用户勾选一个收音机盒,图像显示,并在10秒后,显示一个swf文件。我有图像工作。我尝试在我的html函数中使用php sleep,但是当页面加载时睡眠开始正确,请记住所有这些都需要在onlclick函数中完成。我也尝试使用javascript函数从另一个php文件中获取内容。

<script type="text/javascript">
function doit()
{

  $.get("dumplings.php");
    return false; } 



</script>

Dumplings.php睡了10秒钟,然后用swf回显我的html。这也不起作用。

这是我的收音机盒

<input name="sample_check3" id="sample_check3" value="1" type="radio" onclick="showStuff('img');doit();"/>

1 个答案:

答案 0 :(得分:1)

试试这个:

<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script src="json.json"></script>
<script>
$(document).ready(function () {
    $("#sample_check3").on('click', function(){
        if($(this).attr('checked') === 'checked'){
            $("#image1").css('display','');
            setTimeout(function(){
                $("#image1").css('display','none');
                $("#image2").css('display','');
            },3000);
        }
    });
}); 
</script>
</head>
<body>
<input name="sample_check3" id="sample_check3" value="1" type="radio"/>
<img id="image1" src="http://www.andrew.cmu.edu/user/nguesto/images/pikachu.jpg" style="display:none"/>
<img id="image2" src="http://faqsmedia.ign.com/faqs/image/ani004.gif" style="display:none"/>
</body>
</html>