提醒以下图片

时间:2017-10-29 19:32:45

标签: javascript html html5

我当时想知道我是否可以发出警报并且图片会出现然后消失在这里是我的代码

 <!DOCTYPE html>
    <html lang="en">
    <head>
        <title></title>
        <meta charset="utf-8">

        <style>


        </style>
    </head>
    <body>
     <center><h1>Are you human???</h1></center>
        <button id="button">Yes</button>
     <button onclick="no"  id="no">No</button>
    <script>
    function no(){
        alert("Really you are interesting")

    }

2 个答案:

答案 0 :(得分:1)

您的代码中没有图片。 但如果你的意思是 - 显示警告弹出窗口,你应该添加括号,如 onclick =&#34; no()&#34; 您无法自定义警报窗口。 但是,如果您只想在点击按钮后显示一些图片,则应将<img>display: none添加到页面,onclick将其更改为display: block

答案 1 :(得分:0)

你不能在警告框中放置一张图片。你可以通过在div中放置一个图像来保持display:none来实现它,然后显示隐藏它就像这样

function no() {
  alert("Really you are interesting")
  $("#msg").fadeIn("slow").delay("100").fadeOut("slow");
}
div{
    position:fixed;
    background-color:rgba(0,0,0,0.8);
    width:100%;
    height:100%;
    display:none;
}
<div id="msg">
<img src="https://www.w3.org/html/logo/downloads/HTML5_Logo_512.png"/>
</div>
<center>
  <h1>Are you human???</h1>
</center>
<button id="button">Yes</button>
<button onclick="no()" id="no">No</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>